<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- saved from url=(0080)http://www.whizlabs.com/examprep/mod/quiz/review.php?attempt=170846&showall=true -->
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    
<link rel="stylesheet" type="text/css" href="./OCPJP 6 - Exam Simulator  Final Test_files/styles.php">
<link rel="stylesheet" type="text/css" href="./OCPJP 6 - Exam Simulator  Final Test_files/styles(1).php">

<!--[if IE 7]>
    <link rel="stylesheet" type="text/css" href="http://www.whizlabs.com/examprep/theme/standard/styles_ie7.css" />
<![endif]-->
<!--[if IE 6]>
    <link rel="stylesheet" type="text/css" href="http://www.whizlabs.com/examprep/theme/standard/styles_ie6.css" />
<![endif]-->


    <meta name="keywords" content="moodle, OCPJP 6 - Exam Simulator: Final Test ">
    <title>OCPJP 6 - Exam Simulator: Final Test</title>
    <link rel="shortcut icon" href="http://www.whizlabs.com/examprep/theme/ability-to-learn/favicon.ico">
    <!--<style type="text/css">/*<![CDATA[*/ body{behavior:url(http://www.whizlabs.com/examprep/lib/csshover.htc);} /*]]>*/</style>-->

<script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Final Test_files/javascript-static.js"></script>
<script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Final Test_files/javascript-mod.php"></script>
<script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Final Test_files/overlib.js"></script>
<script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Final Test_files/overlib_cssstyle.js"></script>
<script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Final Test_files/cookies.js"></script>
<script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Final Test_files/ufo.js"></script>
<script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Final Test_files/dropdown.js"></script>  

<script type="text/javascript" defer="defer">
//<![CDATA[
setTimeout('fix_column_widths()', 20);
//]]>
</script>
<script type="text/javascript">
//<![CDATA[
function openpopup(url,name,options,fullscreen) {
  fullurl = "http://www.whizlabs.com/examprep" + url;
  windowobj = window.open(fullurl,name,options);
  if (fullscreen) {
     windowobj.moveTo(0,0);
     windowobj.resizeTo(screen.availWidth,screen.availHeight);
  }
  windowobj.focus();
  return false;
}

function uncheckall() {
  void(d=document);
  void(el=d.getElementsByTagName('INPUT'));
  for(i=0;i<el.length;i++) {
    void(el[i].checked=0);
  }
}

function checkall() {
  void(d=document);
  void(el=d.getElementsByTagName('INPUT'));
  for(i=0;i<el.length;i++) {
    void(el[i].checked=1);
  }
}

function inserttext(text) {
  text = ' ' + text + ' ';
  if ( opener.document.forms['theform'].message.createTextRange && opener.document.forms['theform'].message.caretPos) {
    var caretPos = opener.document.forms['theform'].message.caretPos;
    caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
  } else {
    opener.document.forms['theform'].message.value  += text;
  }
  opener.document.forms['theform'].message.focus();
}

function getElementsByClassName(oElm, strTagName, oClassNames){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var arrRegExpClassNames = new Array();
	if(typeof oClassNames == "object"){
		for(var i=0; i<oClassNames.length; i++){
			arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)"));
		}
	}
	else{
		arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)"));
	}
	var oElement;
	var bMatchesAll;
	for(var j=0; j<arrElements.length; j++){
		oElement = arrElements[j];
		bMatchesAll = true;
		for(var k=0; k<arrRegExpClassNames.length; k++){
			if(!arrRegExpClassNames[k].test(oElement.className)){
				bMatchesAll = false;
				break;
			}
		}
		if(bMatchesAll){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}
//]]>
</script>
    
		<style type="text/css">
	<!--
	#main {
		min-height: 500px;
		width: 988px;
		margin: auto;
		background:#fff;
	}
	#header {
		height: 90px;
		width: 988px;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/header.gif);
	}
	#navi {
		float: left;
		height: 22px;
		width: 828px;
		padding: 10px 0pt 0pt 20px;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-up_02.gif);
	}
	#navi2 {
		height: 32px;
		width: 140px;
		float: left;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/part3left.gif);
		text-align: left;
	}
	#left {
		float: left;
		min-height: 675px;
		width: 263px;
	}
	
	#leftinsertdiv {
		float: left;
		height: 58px;
		width: 263px;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-left-down_04.gif);
	}
	
	#left3 {
		float: left;
		height: 617px;
		width: 21px;
		/*background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-up_05.gif);*/
	}
	
	#left4 {
		height: 58px;
		width: 242px;
		float: right;
	}
	#left5 {
		float: right;
		height: 62px;
		width: 242px;
	}
	#left6 {
		float: right;
		min-height: 160px;
		width: 242px;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-up_06-19.gif);
	}
	#right {
		float: left;
		min-height: 601px;
		width: 725px;
		background:#fff;
	}
	#leftfooter {
		float: left;
		height: 159px;
		width: 263px;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/footerdiv.gif);
		background-repeat:no-repeat;
	}
	#rightfooter {
		float: left;
		height: 50px;
		width: 725px;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-up_10-53.gif);
		background-position:left bottom;
		background-repeat:no-repeat;
		padding-top:90px;
		background-color:#fff;
	}
	#rightfooter2 {
		float: left;
		height: 19px;
		width: 725px;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-up_54.gif);
	}
	-->
	</style>
	
<link href="./OCPJP 6 - Exam Simulator  Final Test_files/css.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>

<script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/document_iterator.js"></script><script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/find_proxy.js"></script><script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/get_html_text.js"></script><script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/global_constants.js"></script><script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/name_injection_builder.js"></script><script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/number_injection_builder.js"></script><script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/string_finder.js"></script><script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/change_sink.js"></script><meta name="document_iterator.js"><meta name="find_proxy.js"><meta name="get_html_text.js"><meta name="global_constants.js"><meta name="name_injection_builder.js"><meta name="number_injection_builder.js"><meta name="string_finder.js"><meta name="change_sink.js"><style charset="utf-8" type="text/css" id="">SPAN.skype_pnh_container SPAN.skype_pnh_mark{  display:none !important;}@media screen{SPAN.skype_pnh_print_container_1323210120{  display:none !important;}SPAN.skype_pnh_container, SPAN.skype_pnh_container *{background-attachment: scroll !important;background-color: transparent !important;background-image: none !important;background-position: 0px 0px ! important;background-repeat: no-repeat !important;border: 0px none !important;border-color: #000000 !important;border-style: none !important;border-width: 0 !important;border-left: 0 none #000000 !important;border-top: 0 none #000000 !important;border-right: 0 none #000000 !important;border-bottom: 0 none #000000 !important;border-left-color: #000000 !important;border-left-style: none !important;border-left-width: 0 !important;border-top-color: #000000 !important;border-top-style: none !important;border-top-width: 0 !important;border-right-color: #000000 !important;border-right-style: none !important;border-right-width: 0 !important;border-bottom-color: #000000 !important;border-bottom-style: none !important;border-bottom-width: 0 !important;border-collapse: separate !important;bottom: auto !important;clear: none !important;clip: auto !important;cursor: pointer !important;direction: ltr !important;display: inline !important;float: none !important;font-style: normal !important;left: auto !important;letter-spacing: 0 !important;list-style-image: none !important;list-style-position: outside !important;list-style-type: disc !important;overflow: hidden !important;overflow-x: hidden !important;overflow-y: hidden !important;padding: 0px 0px 0px 0px !important;padding-left: 0px !important;padding-top: 0px !important;padding-right: 0px !important;padding-bottom: 0px !important;page-break-after: auto !important;page-break-before: auto !important;page-break-inside: auto !important;position: static !important;right: auto !important;table-layout: auto !important;text-align: left !important;text-decoration: none !important;text-indent: 0px !important;text-transform: none !important;top: auto !important;voice-family: inherit !important;white-space: nowrap !important;word-spacing: normal !important;z-index: 0 !important;  color: #49535A !important;  font-family: Tahoma, Arial, Helvetica, sans-serif !important;  font-size: 11px !important;  font-weight: bold !important;  height: 14px !important;  line-height: 14px !important;  margin-left: 0px !important;  margin-top: 0px !important;  margin-right: 0px !important;  margin-bottom: 0px !important;  vertical-align: baseline !important;  width: auto !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_active_fax SPAN.skype_pnh_right_span, SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_inactive_fax SPAN.skype_pnh_right_span{  background-position: -92px 0px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_inactive_free SPAN.skype_pnh_dropart_flag_span{  background-position: 0px 1px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_inactive_free SPAN.skype_pnh_textarea_span{  background-position: -90px 0px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_inactive_free SPAN.skype_pnh_text_span{  visibility: hidden !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_active_free SPAN.skype_pnh_dropart_flag_span{  background-position: 0px 1px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_active_free SPAN.skype_pnh_textarea_span{  background-position: -160px 0px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_active_free SPAN.skype_pnh_text_span{  background-position: -160px 0px !important;  color: #FFFFFF !important;}SPAN.skype_pnh_container SPAN.skype_pnh_left_span{  background-position: 0px 0px !important;  width: 6px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_dropart_span{  background-position: -11px 0px !important;  width: 27px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_dropart_wo_arrow_span{  background-position: -130px 0px !important;  width: 18px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_dropart_flag_span{  background-position: 1px 1px !important;  width: 18px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_textarea_span{  background-position: -125px 0px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_text_span{  padding-left: 5px !important;  background-position: -125px 0px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_right_span{  background-position: -62px 0px !important;  width: 15px !important;}}@media print{SPAN.skype_pnh_print_container_1323210120{}SPAN.skype_pnh_container{    display:none !important;}}@media screen{SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_inactive_common *{  background-image:url('chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/numbers_common_inactive_icon_set.gif') !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_active_common *{  background-image:url('chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/numbers_common_active_icon_set.gif') !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_inactive_fax *{  background-image:url('chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/numbers_common_inactive_icon_set.gif') !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_active_fax *{  background-image:url('chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/numbers_common_active_icon_set.gif') !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_inactive_free *{  background-image:url('chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/numbers_free_icon_set.gif') !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_active_free *{  background-image:url('chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/numbers_free_icon_set.gif') !important;}SPAN.skype_pnh_container SPAN.skype_pnh_dropart_flag_span{  background-image: url('chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/flags.gif') !important;}}</style></head>
<!-- WANT URL-->

<body class="mod-quiz course-11 dir-ltr lang-en_utf8" id="mod-quiz-review" onload="MM_preloadImages(&#39;http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-up_07.gif&#39;,&#39;http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-over_05.gif&#39;);">


<div id="main">
  <div id="header"><br>
    <p class="headertxt">Call Us at <span class="skype_pnh_print_container_1323210120">+1-818-575-6625</span><span class="skype_pnh_container" dir="ltr" tabindex="-1"><span class="skype_pnh_mark"> begin_of_the_skype_highlighting</span>&nbsp;<span class="skype_pnh_highlighting_inactive_common" dir="ltr" skypeaction="skype_dropdown" title="Call this phone number in United States of America with Skype: +18185756625"><span class="skype_pnh_left_span" skypeaction="skype_dropdown" title="Skype actions">&nbsp;&nbsp;</span><span class="skype_pnh_dropart_span" skypeaction="skype_dropdown" title="Skype actions"><span class="skype_pnh_dropart_flag_span" skypeaction="skype_dropdown" style="background-position: -5849px 1px !important; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;&nbsp;&nbsp;</span><span class="skype_pnh_textarea_span"><span class="skype_pnh_text_span">+1-818-575-6625</span></span><span class="skype_pnh_right_span">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span>&nbsp;<span class="skype_pnh_mark">end_of_the_skype_highlighting</span></span> | <a href="http://www.whizlabs.com/examprep/login/logout.php?sesskey=A3za88nMmO">Sign Out</a> | <a href="http://www.whizlabs.com/index.php?option=com_whizmart&view=cart">My Cart</a> | <a href="http://www.whizlabs.com/examprep/user/view.php">Change Password</a></p>
    <p class="txtheader">Welcome <a href="http://www.whizlabs.com/examprep">Flavio&nbsp;Vit !</a></p>
  </div>


  <div id="navi" class="breadcrumb"><h2 class="accesshide ">You are here</h2> <ul>
<li class="first"><a onclick="this.target=&#39;_top&#39;" href="http://www.whizlabs.com/">Home</a></li><li class="first"> <span class="accesshide ">/&nbsp;</span><span class="arrow sep">»</span> <a onclick="this.target=&#39;_top&#39;" href="http://www.whizlabs.com/examprep/">My Account</a></li><li class="first"> <span class="accesshide ">/&nbsp;</span><span class="arrow sep">»</span> <a onclick="this.target=&#39;_top&#39;" href="http://www.whizlabs.com/examprep/course/view.php?id=11">OCPJP 6 - Exam Simulator</a></li><li class="first"> <span class="accesshide ">/&nbsp;</span><span class="arrow sep">»</span> <a onclick="this.target=&#39;_top&#39;" href="http://www.whizlabs.com/examprep/mod/quiz/view.php?id=2206">Final Test</a></li><li class="first"> <span class="accesshide ">/&nbsp;</span><span class="arrow sep">»</span> Review of attempt 1</li></ul>			<div class="navbutton">
				</div>  
  
  <div style="float:right; margin-right:60px;font-size:12px; font-weight:bold; color:#0460AD;">
  	</div>
  </div>

  <div id="navi2">
  <a href="http://www.whizlabs.com/examprep/eddy_report/performance_trak.php?cid=11" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(&#39;Image1&#39;,&#39;&#39;,&#39;http://www.whizlabs.com/examprep/theme/ability-to-learn/images/layerrollov.gif&#39;,1)"><img src="./OCPJP 6 - Exam Simulator  Final Test_files/performace_history.gif" name="Image1" width="125" height="32" border="0" id="Image1"></a></div>
    <!-- END OF HEADER -->
<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div><h2 class="main">Final Test</h2><h2 class="main">Review of attempt 1</h2>
 



<div class="controls">
<div class="singlebutton"><form action="http://www.whizlabs.com/examprep/mod/quiz/view.php" method="get"><div><input type="hidden" name="id" value="2206"><input type="submit" value="Finish review"></div></form></div></div>
<table class="generaltable generalbox quizreviewsummary"><tbody>
<tr><th scope="row" class="cell">Started on</th><td class="cell">Monday,  19 December 2011, 03:48 PM</td></tr>
<tr><th scope="row" class="cell">Completed on</th><td class="cell">Monday,  19 December 2011, 06:08 PM</td></tr>
<tr><th scope="row" class="cell">Time taken</th><td class="cell">2 hours 19 mins</td></tr>
<tr><th scope="row" class="cell">Grade</th><td class="cell"><b>41.75</b> out of a maximum of 60 (<b>70</b>%)</td></tr>
<tr><th scope="row" class="cell">Feedback</th><td class="cell"><p>PASS: Keep it up!</p></td></tr>
</tbody></table>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%201%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q16297" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                1      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will happen if the following code is compiled ? <br><br>class ScannerTest1 <br>{ <br>
<div style="margin-left: 40px;">public static void main(String[] args) throws Exception <br></div>
<div style="margin-left: 40px;">{ <br></div>
<div style="margin-left: 80px;">int i=0; <br>boolean b=false; <br>String s=null; <br>Scanner src=new Scanner(new FileReader("a.txt")); <br>while(src.hasNext()) <br></div>
<div style="margin-left: 80px;">{ <br></div>
<div style="margin-left: 120px;"> if(src.hasNextInt()) #1 <br>
  <div style="margin-left: 40px;">i=src.nextInt(); #2 <br></div>else if(src.hasNextBoolean()) #3 <br>
  <div style="margin-left: 40px;">b=src.nextBoolean(); #4 <br></div>else s=src.next(); <br>
  <div style="margin-left: 40px;"> System.out.println(i+" "+b+" "+s); <br></div></div>
<div style="margin-left: 80px;"> } <br></div>
<div style="margin-left: 40px;">} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16297_61963" name="resp16297_" checked="checked" type="radio" value="61963">        </td>
        <td class="c1 text correct">
          <label for="resp16297_61963">
            <span class="anun">a<span class="anumsep">.</span></span> No Compilation issues.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16297_61964" name="resp16297_" type="radio" value="61964">        </td>
        <td class="c1 text ">
          <label for="resp16297_61964">
            <span class="anun">b<span class="anumsep">.</span></span> Only Compilation error at #1.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16297_61965" name="resp16297_" type="radio" value="61965">        </td>
        <td class="c1 text ">
          <label for="resp16297_61965">
            <span class="anun">c<span class="anumsep">.</span></span> Only Compilation error at #2.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16297_61966" name="resp16297_" type="radio" value="61966">        </td>
        <td class="c1 text ">
          <label for="resp16297_61966">
            <span class="anun">d<span class="anumsep">.</span></span> Only Compilation error at #3.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16297_61967" name="resp16297_" type="radio" value="61967">        </td>
        <td class="c1 text ">
          <label for="resp16297_61967">
            <span class="anun">e<span class="anumsep">.</span></span> Only Compilation error at #4.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16297_62198" name="resp16297_" type="radio" value="62198">        </td>
        <td class="c1 text ">
          <label for="resp16297_62198">
            <span class="anun">f<span class="anumsep">.</span></span> None of the above.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        ANSWER : A <br><br>Explanation: <br>There are no compilation issues in the above code. The Scanner class represents a simple text scanner that can parse primitive types and strings using regular expressions. It can even read input from a file containing different types of data, without knowing the order of the data, in advance. <br><br>The hasNext() method returns true if there is one more token to be read. You can check for exact types of data using the hasNextInt() and the hasNextBoolean() methods. <br><br>The nextInt(), nextBoolean(), and next() methods return the next token of the appropriate type. <br><br>Want to know more? <br> Refer to the following links :<br><a target="_blank" href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html">http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html </a><br><a target="_blank" href="http://java.sun.com/developer/JDCTechTips/2004/tt1201.html#1">http://java.sun.com/developer/JDCTechTips/2004/tt1201.html#1</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%202%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q16298" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                2      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the output of the following code.<br><br>String str="124-532-567-900";<br>String s[] = str.split ("-");<br>int arr[] = new int[ s.length() ];<br>for (int i=0; i &lt;arr.length; i++)<br>{<br>arr[i] = Integer.parseInt(s[i]);<br>System.out.println(arr[i]);<br>}<br><br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16298_61968" name="resp16298_" type="radio" value="61968">        </td>
        <td class="c1 text ">
          <label for="resp16298_61968">
            <span class="anun">a<span class="anumsep">.</span></span> Compilation Error.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16298_61969" name="resp16298_" checked="checked" type="radio" value="61969">        </td>
        <td class="c1 text correct">
          <label for="resp16298_61969">
            <span class="anun">b<span class="anumsep">.</span></span> 124 <br>532<br> 567<br> 900<br>            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16298_61970" name="resp16298_" type="radio" value="61970">        </td>
        <td class="c1 text ">
          <label for="resp16298_61970">
            <span class="anun">c<span class="anumsep">.</span></span> 900<br> 567 <br>532 <br>124            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16298_61971" name="resp16298_" type="radio" value="61971">        </td>
        <td class="c1 text ">
          <label for="resp16298_61971">
            <span class="anun">d<span class="anumsep">.</span></span> None of the above.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        ANSWER : B<br><br>Explanation:<br>The split method of the String class splits a string around matches of the given regular expression. The return value is a String array containing the tokens. In this case, we split on the expression "-" and the tokens are stored in the array s. <br><br>Now each element of the String array is converted to the int type using the Integer.parseInt method.<br><br>Refer to String class API at<br><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html" target="_blank">http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html</a><br>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%203%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q16299" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                3      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will happen if the following code is compiled.<br><br>Date d= new Date(); <br><br>DateFormat myFormat = new DateFormat(); #1<br><br>myFormat.setTimeZone(TimeZone.getTimeZone("CST")); #2<br><br>System.out.println(myFormat.format(d)); #3</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16299_61972" name="resp16299_" checked="checked" type="radio" value="61972">        </td>
        <td class="c1 text correct">
          <label for="resp16299_61972">
            <span class="anun">a<span class="anumsep">.</span></span> Compilation Error at #1.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16299_61973" name="resp16299_" type="radio" value="61973">        </td>
        <td class="c1 text ">
          <label for="resp16299_61973">
            <span class="anun">b<span class="anumsep">.</span></span> Compilation Error at #2.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16299_61974" name="resp16299_" type="radio" value="61974">        </td>
        <td class="c1 text ">
          <label for="resp16299_61974">
            <span class="anun">c<span class="anumsep">.</span></span> Compilation Error at #3.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16299_61975" name="resp16299_" type="radio" value="61975">        </td>
        <td class="c1 text ">
          <label for="resp16299_61975">
            <span class="anun">d<span class="anumsep">.</span></span> No compilation issues.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16299_61976" name="resp16299_" type="radio" value="61976">        </td>
        <td class="c1 text ">
          <label for="resp16299_61976">
            <span class="anun">e<span class="anumsep">.</span></span> None of the above.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        ANSWER : A<br><br>Explanation:<br>DateFormat is an abstract class for date/time formatting subclasses, which formats and parses dates or time in a locale/language-independent manner. Since the class is abstract, we use one of the factory methods to get the date/time formatter with the default formatting style for the default locale. The setTimezone method sets the time zone for the calendar of the DateFormat object. To format a date for the current Locale, use the format method of the DateFormat class.<br><br>myString = DateFormat.getDateInstance().format(myDate);<br><br>More information is available at<br><a href="http://java.sun.com/j2se/1.4.2/docs/api/java/text/DateFormat.html" target="_blank">http://java.sun.com/j2se/1.4.2/docs/api/java/text/DateFormat.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%204%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q16300" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                4      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Choose the correct option to create a BufferedReader to read from a file a.txt.</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16300_61977" name="resp16300_" checked="checked" type="radio" value="61977">        </td>
        <td class="c1 text ">
          <label for="resp16300_61977">
            <span class="anun">a<span class="anumsep">.</span></span> Reader reader=new  BufferedReader(new FileInputStream("a.txt"));            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16300_61978" name="resp16300_" type="radio" value="61978">        </td>
        <td class="c1 text ">
          <label for="resp16300_61978">
            <span class="anun">b<span class="anumsep">.</span></span> Reader reader=new  BufferedReader("a.txt");            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16300_61979" name="resp16300_" type="radio" value="61979">        </td>
        <td class="c1 text correct">
          <label for="resp16300_61979">
            <span class="anun">c<span class="anumsep">.</span></span> Reader reader=new  BufferedReader(new FileReader("a.txt"));            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16300_61980" name="resp16300_" type="radio" value="61980">        </td>
        <td class="c1 text ">
          <label for="resp16300_61980">
            <span class="anun">d<span class="anumsep">.</span></span> None of the above.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        ANSWER : C<br><br>Explanation:<br>The java.io.Reader class is an abstract class for reading character streams. BufferedReader is a subclass of Reader, which buffers characters, so as to allow efficient reading. It can be wrapped around readers like FileReader or InputStreamReader. <br><br>The BufferedReader has no constructors that take File class as argument. FileInputStream is used for reading bytes; hence, it cannot be passed to the BufferedReader constructor. <br><br>Reference:<br><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/io/BufferedReader.html" target="_blank">http://java.sun.com/j2se/1.5.0/docs/api/java/io/BufferedReader.html</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%205%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10593" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                5      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the following code? <br><br>class StringBufferTest{ <br>public static void main(String[] args){<br> 1. StringBuffer result = new StringBuffer(); <br>2. StringBuffer s=null; <br>3. result.append(s); <br>4. result.insert(0,"123");<br> 5. System.out.println(result);<br> }<br> }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10593_50143" name="resp10593_" type="radio" value="50143">        </td>
        <td class="c1 text ">
          <label for="resp10593_50143">
            <span class="anun">a<span class="anumsep">.</span></span> Compiler error at line 1            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10593_50144" name="resp10593_" type="radio" value="50144">        </td>
        <td class="c1 text ">
          <label for="resp10593_50144">
            <span class="anun">b<span class="anumsep">.</span></span> Compiler error at line 3            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10593_50145" name="resp10593_" type="radio" value="50145">        </td>
        <td class="c1 text ">
          <label for="resp10593_50145">
            <span class="anun">c<span class="anumsep">.</span></span> Compiler error at line 4            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10593_50146" name="resp10593_" checked="checked" type="radio" value="50146">        </td>
        <td class="c1 text ">
          <label for="resp10593_50146">
            <span class="anun">d<span class="anumsep">.</span></span> NullPointerException            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10593_50147" name="resp10593_" type="radio" value="50147">        </td>
        <td class="c1 text ">
          <label for="resp10593_50147">
            <span class="anun">e<span class="anumsep">.</span></span> StringIndexOutOfBoundsException            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10593_50148" name="resp10593_" type="radio" value="50148">        </td>
        <td class="c1 text correct">
          <label for="resp10593_50148">
            <span class="anun">f<span class="anumsep">.</span></span> Prints "123null"            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice F is the correct answer.<br><br> This code compiles fine and prints "123null". <br><br>The StringBuffer object s is constructed using the parameterless constructor, so it is empty at first. If the argument passed to the append method is null, then the four characters "null" are appended to the invoking StringBuffer object. So now sb refers to null. <br><br>The insert method causes the characters of the String argument to be inserted, in order, into this StringBuffer at the indicated offset, moving up any characters originally above that position and increasing the length of this sequence by the length of the argument. <br><br>Here the insert method is invoked with an offset of 0, and the argument passed is "123". So the result is "123null" which is printed out. <br><br>For more information, you may refer to <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/StringBuffer.html">http://java.sun.com/j2se/1.5.0/docs/api/java/lang/StringBuffer.html</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%206%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10592" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                6      </div>
      </div>
  <div class="content">
    <div class="qtext">
  If the complete date/time information is Mon May 23 09:05:28 PM GMT+05:30 2005, what will be printed out by the following program? <br><br>class Format2<br>{ <br>
<div style="margin-left: 40px;">public static void main(String[] args)<br>{ <br>
  <div style="margin-left: 40px;">Formatter fmt=new Formatter(); <br>Calendar cal=Calendar.getInstance(); <br>fmt.format("%tr %tZ",cal,cal); <br>System.out.println(fmt); <br></div>}<br></div> }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10592_50138" name="resp10592_" checked="checked" type="radio" value="50138">        </td>
        <td class="c1 text correct">
          <label for="resp10592_50138">
            <span class="anun">a<span class="anumsep">.</span></span> 09:05:28 PM GMT+05:30            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10592_50139" name="resp10592_" type="radio" value="50139">        </td>
        <td class="c1 text ">
          <label for="resp10592_50139">
            <span class="anun">b<span class="anumsep">.</span></span> 21:05:28 2005            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10592_50140" name="resp10592_" type="radio" value="50140">        </td>
        <td class="c1 text ">
          <label for="resp10592_50140">
            <span class="anun">c<span class="anumsep">.</span></span> Mon 21:05:28 GMT+05:30 2005            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10592_50141" name="resp10592_" type="radio" value="50141">        </td>
        <td class="c1 text ">
          <label for="resp10592_50141">
            <span class="anun">d<span class="anumsep">.</span></span> 21:05:28 GMT+05:30            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10592_50142" name="resp10592_" type="radio" value="50142">        </td>
        <td class="c1 text ">
          <label for="resp10592_50142">
            <span class="anun">e<span class="anumsep">.</span></span> May 23 09:05:28 PM GMT+05:30            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice A is the correct answer.<br><br> The Formatter class provides format conversions that let you display numbers, strings, time, and date according to the specified format string. The %t specifier lets you format date and time information; it uses a suffix to describe the exact format required. The suffix 'r' is replaced by the 'hh:mm:ss' format (12 hr format), which in this case, is '09:05:28 PM'. The suffix 'Z' gives the time zone, which in this case is 'GMT+05:30'.<br><br> To know more about the Formatter, refer to<br><a href="http://java.sun.com/developer/JDCTechTips/2004/tt1005.html#2">http://java.sun.com/developer/JDCTechTips/2004/tt1005.html#2</a><br> <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/logging/Formatter.html">http://java.sun.com/j2se/1.5.0/docs/api/java/util/logging/Formatter.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%207%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10594" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                7      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the following code? <br><br>public class NumberTest <br>{ <br>
<div style="margin-left: 40px;">public static void main(String[] args) <br>{<br>
  <div style="margin-left: 40px;"> print(3.0);<br></div> } <br>private static void print(Number n) <br>{ <br>
  <div style="margin-left: 40px;">System.out.println("Number"); <br></div>} <br>private static void print(Float n) <br>{<br>
  <div style="margin-left: 40px;"> System.out.println("Float"); <br></div>}<br></div> }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10594_50149" name="resp10594_" type="radio" value="50149">        </td>
        <td class="c1 text ">
          <label for="resp10594_50149">
            <span class="anun">a<span class="anumsep">.</span></span> Does not compile            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10594_50150" name="resp10594_" checked="checked" type="radio" value="50150">        </td>
        <td class="c1 text correct">
          <label for="resp10594_50150">
            <span class="anun">b<span class="anumsep">.</span></span> Prints "Number"            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10594_50151" name="resp10594_" type="radio" value="50151">        </td>
        <td class="c1 text ">
          <label for="resp10594_50151">
            <span class="anun">c<span class="anumsep">.</span></span> Prints "Float"            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10594_50152" name="resp10594_" type="radio" value="50152">        </td>
        <td class="c1 text ">
          <label for="resp10594_50152">
            <span class="anun">d<span class="anumsep">.</span></span> None of these            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice B is the correct answer.<br><br> The default type of a floating point literal is double, and not float. If you want to indicate that a literal is float, you need to add 'F' or 'f' after the value. So, here 3.0 is taken as double, autoboxed to Double and passed to the print method which takes a Number as argument. <br><br>This method matches the method call because Number is the superclass of Double and a subclass object can be passed to a superclass object reference. <br><br>Choice A is incorrect since the program compiles fine. <br><br>Choice C is incorrect because the Float version of the method is not called. <br><br>Since choice B is correct, choice D is incorrect. <br><br>To know more about autoboxing and unboxing, please refer to <br><a href="http://java.sun.com/docs/books/jls/third_edition/html/conversions.html#5.1.7">http://java.sun.com/docs/books/jls/third_edition/html/conversions.html#5.1.7</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%208%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10595" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                8      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will be written to the standard output when the following program is run?<br> <br>public class Test <br>{ <br>
<div style="margin-left: 40px;">public static void main(String[] args) <br>{ <br>
  <div style="margin-left: 40px;">String space = " "; <br>String composite = space + "hello" + space + space; <br>composite.concat("world"); <br>String trimmed = composite.trim(); <br>System.out.println(trimmed.length()); <br></div>} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10595_50153" name="resp10595_" checked="checked" type="radio" value="50153">        </td>
        <td class="c1 text correct">
          <label for="resp10595_50153">
            <span class="anun">a<span class="anumsep">.</span></span> 5            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10595_50154" name="resp10595_" type="radio" value="50154">        </td>
        <td class="c1 text ">
          <label for="resp10595_50154">
            <span class="anun">b<span class="anumsep">.</span></span> 6            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10595_50155" name="resp10595_" type="radio" value="50155">        </td>
        <td class="c1 text ">
          <label for="resp10595_50155">
            <span class="anun">c<span class="anumsep">.</span></span> 7            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10595_50156" name="resp10595_" type="radio" value="50156">        </td>
        <td class="c1 text ">
          <label for="resp10595_50156">
            <span class="anun">d<span class="anumsep">.</span></span> 12            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10595_50157" name="resp10595_" type="radio" value="50157">        </td>
        <td class="c1 text ">
          <label for="resp10595_50157">
            <span class="anun">e<span class="anumsep">.</span></span> 13            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice A is the correct answer.<br><br> Strings are immutable, therefore the concat() method has no effect on the original String object. <br><br>The string on which the trim() method is called consists of 8 characters, where the first and the two last characters are spaces (" hello "). <br><br>The trim() method returns a new String object where the white space characters at each end have been removed. <br><br>This leaves the 5 characters of the word "hello".<br><br> Reference: <br><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html">http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%209%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10596" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                9      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the following code? <br><br>class PrintTest<br>{ <br>
<div style="margin-left: 40px;">public static void main(String[] args) <br>{ <br>
  <div style="margin-left: 40px;">double d=222.4578;<br> System.out.printf("% .2f",d);<br></div> }<br></div> }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10596_50158" name="resp10596_" type="radio" value="50158">        </td>
        <td class="c1 text ">
          <label for="resp10596_50158">
            <span class="anun">a<span class="anumsep">.</span></span> Does not compile            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10596_50159" name="resp10596_" type="radio" value="50159">        </td>
        <td class="c1 text ">
          <label for="resp10596_50159">
            <span class="anun">b<span class="anumsep">.</span></span> Throws IllegalFormatConversionException            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10596_50160" name="resp10596_" checked="checked" type="radio" value="50160">        </td>
        <td class="c1 text correct">
          <label for="resp10596_50160">
            <span class="anun">c<span class="anumsep">.</span></span> Prints 222.46            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10596_50161" name="resp10596_" type="radio" value="50161">        </td>
        <td class="c1 text ">
          <label for="resp10596_50161">
            <span class="anun">d<span class="anumsep">.</span></span> Prints 222.45            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10596_50162" name="resp10596_" type="radio" value="50162">        </td>
        <td class="c1 text ">
          <label for="resp10596_50162">
            <span class="anun">e<span class="anumsep">.</span></span> Prints 2.224578            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10596_50163" name="resp10596_" type="radio" value="50163">        </td>
        <td class="c1 text ">
          <label for="resp10596_50163">
            <span class="anun">f<span class="anumsep">.</span></span> Prints .2224578            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice C is the correct answer.<br><br> For floating-point conversions using %f, the precision is the number of digits after the decimal separator. So 0.2f has 2 as the precision, i.e., there must be 2 digits after the decimal point, rounding off is done if necessary. <br><br>Here the value is rounded to 222.46. So choices D, E and F are incorrect. <br><br>There are no compiler errors or exceptions, so choices A and B are also incorrect. <br><br>You can get more information about the printf method at <a href="http://java.sun.com/j2se/5.0/docs/api/java/io/PrintStream.html">http://java.sun.com/j2se/5.0/docs/api/java/io/PrintStream.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2010%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10597" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                10      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the following code? <br><br>import java.util.regex.*; <br>class PatternTest<br>{ <br>
<div style="margin-left: 40px;">public static void main(String[] args)<br>{ <br>
  <div style="margin-left: 40px;">Pattern p = Pattern.compile("x*y"); <br>Matcher m = p.matcher("xxxy"); <br>boolean b = m.matches(); <br>System.out.println(b); <br></div>}<br></div> }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10597_50164" name="resp10597_" type="radio" value="50164">        </td>
        <td class="c1 text ">
          <label for="resp10597_50164">
            <span class="anun">a<span class="anumsep">.</span></span> Does not compile            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10597_50165" name="resp10597_" checked="checked" type="radio" value="50165">        </td>
        <td class="c1 text correct">
          <label for="resp10597_50165">
            <span class="anun">b<span class="anumsep">.</span></span> Prints true            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10597_50166" name="resp10597_" type="radio" value="50166">        </td>
        <td class="c1 text ">
          <label for="resp10597_50166">
            <span class="anun">c<span class="anumsep">.</span></span> Prints false            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10597_50167" name="resp10597_" type="radio" value="50167">        </td>
        <td class="c1 text ">
          <label for="resp10597_50167">
            <span class="anun">d<span class="anumsep">.</span></span> Causes an exception at runtime            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice B is the correct answer.<br><br> A regular expression, specified as a string, must first be compiled into an instance of the Pattern class. <br><br>The resulting pattern can then be used to create a Matcher object that can match arbitrary character sequences against the regular expression. <br><br>The * operator is used to indicate zero or more occurrences. So, x*y means zero or more occurrences of x followed by y. This matches the "xxxy" string, thus the matches method returns true. <br><br>Hence, choice C is incorrect. Since there are no compiler errors or exceptions, choices A and D are incorrect.<br><br> Want to know more? Check out <a href="http://java.sun.com/docs/books/tutorial/extra/regex/pattern.html">http://java.sun.com/docs/books/tutorial/extra/regex/pattern.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2011%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10598" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                11      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the following code, assuming that the file bb.txt does not exist? <br><br>class WriterTest<br>{ <br>
<div style="margin-left: 40px;">public static void main(String[] args) throws IOException<br>{ <br>
  <div style="margin-left: 40px;">Writer w=new BufferedWriter(new FileWriter("bb.txt"));// Line1<br> w.write(1); // Line2<br> w.close(); <br></div>}<br></div> }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10598_50168" name="resp10598_" type="radio" value="50168">        </td>
        <td class="c1 text ">
          <label for="resp10598_50168">
            <span class="anun">a<span class="anumsep">.</span></span> Compiler error            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10598_50169" name="resp10598_" type="radio" value="50169">        </td>
        <td class="c1 text ">
          <label for="resp10598_50169">
            <span class="anun">b<span class="anumsep">.</span></span> FileNotFoundException thrown at line 1            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10598_50170" name="resp10598_" type="radio" value="50170">        </td>
        <td class="c1 text ">
          <label for="resp10598_50170">
            <span class="anun">c<span class="anumsep">.</span></span> IOException thrown at line 2            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10598_50171" name="resp10598_" checked="checked" type="radio" value="50171">        </td>
        <td class="c1 text correct">
          <label for="resp10598_50171">
            <span class="anun">d<span class="anumsep">.</span></span> None of these            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice D is the correct answer.<br><br> The FileWriter constructor does not throw FileNotFoundException, if the named file does not exist. In this case, a new file is created by the constructor, if the underlying platform allows this operation. <br><br>If the named file exists, but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason, the constructor itself throws IOException. So choice D is correct, while choice C is incorrect. <br><br>Choice A is incorrect because there are no compiler errors in the given code.<br><br> Refer to the FileWriter API at <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/io/FileWriter.html">http://java.sun.com/j2se/1.5.0/docs/api/java/io/FileWriter.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2012%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q16301" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                12      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will happen if the following code is compiled.<br><br>ArrayList&lt;String&gt; l = new ArrayList&lt;String&gt;(); #1<br><br>l1= Collections.synchronizedList(l); #2<br><br>String[] s=l1.toArray ; #3</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16301_61981" name="resp16301_" type="radio" value="61981">        </td>
        <td class="c1 text ">
          <label for="resp16301_61981">
            <span class="anun">a<span class="anumsep">.</span></span> Compilation Error at #1.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16301_61982" name="resp16301_" type="radio" value="61982">        </td>
        <td class="c1 text ">
          <label for="resp16301_61982">
            <span class="anun">b<span class="anumsep">.</span></span> Compilation Error at #2.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16301_61983" name="resp16301_" checked="checked" type="radio" value="61983">        </td>
        <td class="c1 text ">
          <label for="resp16301_61983">
            <span class="anun">c<span class="anumsep">.</span></span> Compilation Error at #3.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16301_61984" name="resp16301_" type="radio" value="61984">        </td>
        <td class="c1 text correct">
          <label for="resp16301_61984">
            <span class="anun">d<span class="anumsep">.</span></span> No compilation issues.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        ANSWER : D<br><br>Explanation:<br>The static method Collections.synchronizedList(List list) returns a synchronized (thread-safe) list backed by the specified list. Since the return type of this method is List, the return value has to be received in a variable of type List&lt;String&gt; and not ArrayList&lt;String&gt;. <br><br>The toArray method returns an array containing all the elements in this collection; the runtime type of the returned array is that of the specified array. In this case, since we pass new String[0] to the toArray method, it returns an array of String.<br><br>Reference:<br><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collections.html" target="_blank">http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collections.html</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2013%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q16302" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                13      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following options will compile ?<br>(Choose four options)<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16302_61985" name="resp16302_61985" type="checkbox" value="61985">        </td>
        <td class="c1 text correct">
          <label for="resp16302_61985">
            <span class="anun">a<span class="anumsep">.</span></span> Vector&lt;Number&gt; c1==new Vector&lt;Number&gt;();            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16302_61986" name="resp16302_61986" checked="checked" type="checkbox" value="61986">        </td>
        <td class="c1 text ">
          <label for="resp16302_61986">
            <span class="anun">b<span class="anumsep">.</span></span> List&lt;Integer&gt; c2=new List&lt;Integer&gt;();            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16302_61987" name="resp16302_61987" checked="checked" type="checkbox" value="61987">        </td>
        <td class="c1 text correct">
          <label for="resp16302_61987">
            <span class="anun">c<span class="anumsep">.</span></span> HashSet&lt;?&gt; c3=new HashSet&lt;String&gt;();            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16302_61988" name="resp16302_61988" checked="checked" type="checkbox" value="61988">        </td>
        <td class="c1 text correct">
          <label for="resp16302_61988">
            <span class="anun">d<span class="anumsep">.</span></span> Set &lt;? extends Number&gt; c4=new  TreeSet&lt;Number&gt;();            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16302_61989" name="resp16302_61989" checked="checked" type="checkbox" value="61989">        </td>
        <td class="c1 text correct">
          <label for="resp16302_61989">
            <span class="anun">e<span class="anumsep">.</span></span> Set&lt;? super Number&gt; c5=new  TreeSet&lt;Object&gt;();            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        ANSWER : A,C,D,E<br><br>Explanation:<br>Even though Number is an abstract class, it is legal to instantiate Vector&lt;Number&gt; which indicates a Vector which will accept only objects of type Number. So it is legal to state the following - <br><br>Vector&lt;Number&gt; c1=new Vector&lt;Number&gt;();<br><br>Since Vector&lt;Integer&gt; is a subtype of List&lt;Integer&gt;, this assignment is also legal.<br><br>HashSet&lt;?&gt; indicates a HashSet which can contain elements whose type is unknown at compile time, so assigning HashSet&lt;String&gt; to it is allowed. <br><br>The wild card notation Set&lt;? extends Number&gt; indicates a Set which can accept Number or any of its subtypes. So assigning TreeSet&lt;Number&gt; to Set&lt;? extends Number&gt; is allowed. <br><br>The wild card notation Set&lt;? super Number&gt; indicates a Set which can accept any supertype of Number, so assigning TreeSet&lt;Object&gt; to it is perfectly legal.<br><br>Reference:<br><a href="http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf" target="_blank">http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf </a>      </div>
        <div class="grading">
      <div class="correctness  partiallycorrect">Partially correct</div><div class="gradingdetails">Marks for this submission: 0.75/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2014%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q16303" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                14      </div>
      </div>
  <div class="content">
    <div class="qtext">
  You want to find the largest integer in the given array. Choose the correct code excerpts to achieve this. <br><br>Integer [] a={22,3,5,66,45};</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16303_61990" name="resp16303_" checked="checked" type="radio" value="61990">        </td>
        <td class="c1 text ">
          <label for="resp16303_61990">
            <span class="anun">a<span class="anumsep">.</span></span> int i = Collections.max(Arrays.toList(a));            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16303_61991" name="resp16303_" type="radio" value="61991">        </td>
        <td class="c1 text ">
          <label for="resp16303_61991">
            <span class="anun">b<span class="anumsep">.</span></span> int i = Collection.max(Arrays.toList(a));            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16303_61992" name="resp16303_" type="radio" value="61992">        </td>
        <td class="c1 text correct">
          <label for="resp16303_61992">
            <span class="anun">c<span class="anumsep">.</span></span> int i = Collections.max(Arrays.asList(a));            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16303_61993" name="resp16303_" type="radio" value="61993">        </td>
        <td class="c1 text ">
          <label for="resp16303_61993">
            <span class="anun">d<span class="anumsep">.</span></span> int i = Collection.max(Arrays.asList(a));            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        ANSWER : C<br><br>Explanation:<br>The asList method of the Arrays class returns a List that contains the same elements as the given array. Now we can call the max method of the Collections class that returns the element with the maximum value out of the elements in the given collection, according to the natural ordering of its elements. The resulting Integer object is autoboxed into the primitive int type.<br><br>Reference:<br><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Arrays.html" target="_blank">http://java.sun.com/j2se/1.5.0/docs/api/java/util/Arrays.html</a><br>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2015%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q16304" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                15      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the output when the following code is run ?<br><br>Map&lt;Integer, String &gt; map = new HashMap&lt;Integer, String&gt; () ; <br>map.put(663, "Tim"); <br>map.put(11, "John"); <br>map.put(23, "Leo"); <br>map.put(999, "Jim"); <br>for( Map.Entry pairs : map.entrySet()) <br>System.out.println(pairs.getKey() + " = " + pairs.getValue());</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16304_61994" name="resp16304_" type="radio" value="61994">        </td>
        <td class="c1 text ">
          <label for="resp16304_61994">
            <span class="anun">a<span class="anumsep">.</span></span> Compilation Error.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16304_61995" name="resp16304_" type="radio" value="61995">        </td>
        <td class="c1 text ">
          <label for="resp16304_61995">
            <span class="anun">b<span class="anumsep">.</span></span> 999 = Jim<br>  23 = Leo<br>  11 = John  <br>663 = Tim             <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16304_61996" name="resp16304_" type="radio" value="61996">        </td>
        <td class="c1 text ">
          <label for="resp16304_61996">
            <span class="anun">c<span class="anumsep">.</span></span> 11 = John  <br>663 = Tim <br> 999 = Jim  <br>23 = Leo            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16304_61997" name="resp16304_" checked="checked" type="radio" value="61997">        </td>
        <td class="c1 text correct">
          <label for="resp16304_61997">
            <span class="anun">d<span class="anumsep">.</span></span> Can't be determined.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        ANSWER : D<br><br>Explanation:<br>A Map interface is implemented by an object that maps unique keys to values. Here, the key is of Integer type and the value of String type. <br><br>The HashMap class is an efficient implementation of the Map interface, which does not guarantee any ordering for the keys. Hence the answer D.<br><br>The entrySet() method of Map returns a Set view of the mappings contained in this Map. Here, we use the enhanced for loop to iterate through the Set, each element in the Set is a Map.Entry, from which the key and the value can be obtained.<br><br>Read more about HashMap at<br><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/HashMap.html" target="_blank">http://java.sun.com/j2se/1.5.0/docs/api/java/util/HashMap.html</a><br>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2016%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q16305" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                16      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which interface is to be implemented by the elements of TreeSet so that they are sorted according to their natural ordering ?<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16305_61998" name="resp16305_" checked="checked" type="radio" value="61998">        </td>
        <td class="c1 text ">
          <label for="resp16305_61998">
            <span class="anun">a<span class="anumsep">.</span></span> java.util.Comparable.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16305_61999" name="resp16305_" type="radio" value="61999">        </td>
        <td class="c1 text correct">
          <label for="resp16305_61999">
            <span class="anun">b<span class="anumsep">.</span></span> java.lang.Comparable.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16305_62000" name="resp16305_" type="radio" value="62000">        </td>
        <td class="c1 text ">
          <label for="resp16305_62000">
            <span class="anun">c<span class="anumsep">.</span></span> java.lang.Comparator.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16305_62001" name="resp16305_" type="radio" value="62001">        </td>
        <td class="c1 text ">
          <label for="resp16305_62001">
            <span class="anun">d<span class="anumsep">.</span></span> java.util.Comparator.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16305_62002" name="resp16305_" type="radio" value="62002">        </td>
        <td class="c1 text ">
          <label for="resp16305_62002">
            <span class="anun">e<span class="anumsep">.</span></span> None of the above.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        ANSWER : B<br><br>Explanation:<br>The java.lang.Comparable interface imposes a total ordering on the objects of each class that implements it. This ordering is referred to as the class's natural ordering. So this interface is to be implemented by the elements of a TreeSet so that they are sorted in the natural order.<br>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2017%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10601" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                17      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following statements are true about the default implementation of the public int hashCode() method of the Object class? Select two choices.<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10601_50182" name="resp10601_50182" checked="checked" type="checkbox" value="50182">        </td>
        <td class="c1 text ">
          <label for="resp10601_50182">
            <span class="anun">a<span class="anumsep">.</span></span> The Object class does not provide any implementation for the hashCode method; every class must override it.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10601_50183" name="resp10601_50183" type="checkbox" value="50183">        </td>
        <td class="c1 text correct">
          <label for="resp10601_50183">
            <span class="anun">b<span class="anumsep">.</span></span> As far as it may be practically possible, the hashCode method defined by the Object class does return distinct integers for distinct objects.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10601_50184" name="resp10601_50184" checked="checked" type="checkbox" value="50184">        </td>
        <td class="c1 text correct">
          <label for="resp10601_50184">
            <span class="anun">c<span class="anumsep">.</span></span> For two object references referring to the same object, the hashCode method returns the same integer.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10601_50185" name="resp10601_50185" type="checkbox" value="50185">        </td>
        <td class="c1 text ">
          <label for="resp10601_50185">
            <span class="anun">d<span class="anumsep">.</span></span> It returns a fixed number that internally represents the Object class for the JVM.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10601_50186" name="resp10601_50186" type="checkbox" value="50186">        </td>
        <td class="c1 text ">
          <label for="resp10601_50186">
            <span class="anun">e<span class="anumsep">.</span></span> Only choice D is correct.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices B and C are the correct answers.<br><br> The Object class does implement the hashCode method. This default implementation of the hashCode method is in accordance with the default implementation of the equals() method in the Object class. <br><br>This is what the API says about it - <br>
<ul>
  <li>Returns a hash code value for the object.</li>
  <li>This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.</li>
</ul>The general contract of the hashCode method is: <br><br>Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.<br>
<ul>
  <li> If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer as the result.</li>
  <li>It is not required that if two objects are unequal according to the equals(java.lang.Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects might improve the performance of hashtables. <br></li>
</ul>Also, as much as is reasonably practical, the hashCode method defined by the Object class does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the Java programming language.) <br><br>Choice D is incorrect because the returned number has no relation with the class of the object. <br><br>Hence, choice E is also incorrect.<br><br> More information is available at <a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/Object.html">http://java.sun.com/j2se/1.3/docs/api/java/lang/Object.html</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2018%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10602" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                18      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the following code? <br><br>import java.util.*; <br>class Gen&lt;T&gt; <br>{<br>
<div style="margin-left: 40px;"> T obj; <br>Gen(T o)<br>{ <br>
  <div style="margin-left: 40px;">obj=o; <br></div>} <br>T get() <br>{ <br>
  <div style="margin-left: 40px;">return obj; <br></div>}<br></div> }<br><br>class Generics19<br>{ <br>
<div style="margin-left: 40px;">public static void main(String[] args)<br>{ <br>
  <div style="margin-left: 40px;">Gen&lt;Integer&gt; i1=new Gen&lt;Integer&gt;(new Integer(10)); <br>int i=i1.get(); <br>System.out.println(i); <br></div>}<br></div> }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10602_50187" name="resp10602_" type="radio" value="50187">        </td>
        <td class="c1 text ">
          <label for="resp10602_50187">
            <span class="anun">a<span class="anumsep">.</span></span> Compiler error            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10602_50188" name="resp10602_" type="radio" value="50188">        </td>
        <td class="c1 text ">
          <label for="resp10602_50188">
            <span class="anun">b<span class="anumsep">.</span></span> Exception            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10602_50189" name="resp10602_" checked="checked" type="radio" value="50189">        </td>
        <td class="c1 text correct">
          <label for="resp10602_50189">
            <span class="anun">c<span class="anumsep">.</span></span> Prints 10            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10602_50190" name="resp10602_" type="radio" value="50190">        </td>
        <td class="c1 text ">
          <label for="resp10602_50190">
            <span class="anun">d<span class="anumsep">.</span></span> Prints 0            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice C is the correct answer.<br><br> The Gen class is a generic class, T is the name of a type parameter to which we can assign any type. Here, we pass Integer as the type argument value for T. <br><br>Gen&lt;Integer&gt; i1=new Gen&lt;Integer&gt;(new Integer(10));<br><br> The return type of the get() method is Integer, but we can receive it in an int variable because Integer unboxes into int. So the value received in i is 10. Thus, the output is 10. Hence, choice D is incorrect. <br><br>There are no compiler errors or exceptions generated here, so choices A and B are incorrect.<br><br> For more information, check out<br><a href="http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf">http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2019%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10603" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                19      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Select the most appropriate implementation of the hashCode() method that can be inserted at line 15 in the following code. Assume that the equals() method is implemented correctly in this class. <br><br>1. public class TestHash <br>2. { <br>3. private int length; <br>4. private int width; <br>5. private final double area; <br>6.<br> 7. // only one constructor <br>8. public TestHash(int l, int w) <br>9. { <br>10. length = l; <br>11. width = w; <br>12. area = length * width; <br>13. } <br>14. <br>15. // what should be inserted here? <br>16. <br>17. // equals method not shown <br>18. }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10603_50191" name="resp10603_" type="radio" value="50191">        </td>
        <td class="c1 text ">
          <label for="resp10603_50191">
            <span class="anun">a<span class="anumsep">.</span></span> public int hashCode() <br> &nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int hash = 7;<br>  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hash = 31 * hash + length;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hash = 31 * hash + width;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;long bits = Double.doubleToLongBits(area); <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return hash; <br> &nbsp;&nbsp;&nbsp;&nbsp;}            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10603_50192" name="resp10603_" type="radio" value="50192">        </td>
        <td class="c1 text ">
          <label for="resp10603_50192">
            <span class="anun">b<span class="anumsep">.</span></span>  public int hashCode()<br>  &nbsp;&nbsp;&nbsp;&nbsp;{<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int hash = 7;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hash = 31 * hash + length;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hash = 31 * hash + width;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;long bits = Double.doubleToLongBits(area); <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hash = 31 * hash + (int)(bits  (bits &gt;&gt;&gt; 32));<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return hash; <br> &nbsp;&nbsp;&nbsp;&nbsp;}            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10603_50193" name="resp10603_" checked="checked" type="radio" value="50193">        </td>
        <td class="c1 text correct">
          <label for="resp10603_50193">
            <span class="anun">c<span class="anumsep">.</span></span> public int hashCode()<br> &nbsp;&nbsp;&nbsp;&nbsp;{<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int hash = 7;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hash = 31 * hash + length;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hash = 31 * hash + width;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return hash; <br> &nbsp;&nbsp;&nbsp;&nbsp;}            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10603_50194" name="resp10603_" type="radio" value="50194">        </td>
        <td class="c1 text ">
          <label for="resp10603_50194">
            <span class="anun">d<span class="anumsep">.</span></span> public long hashCode()<br>  &nbsp;&nbsp;&nbsp;&nbsp;{<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int hash = 7; <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hash = 31 * hash + length;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return hash;<br> &nbsp;&nbsp;&nbsp;&nbsp;}            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice C is the correct answer.<br><br> The code snippet given in choice C is the most appropriate implementation of the hashCode() method that can be inserted at line 15. The variable "area" is an insignificant variable here; its value can be computed from the other two variables - length and width. Also, the fact that "area" is a final variable indicates that its value cannot be changed later. Hence, it should not be included in the computation of the hash code value for the objects of this class. Thus, choices A and B are inappropriate. <br><br>The code snippet in choice D returns "long" instead of "int", hence it will not even compile. Obviously, choice D is incorrect. <br><br>Only code snippet in choice C uses both significant variables and excludes "area", which can be computed from the other two variables. Hence, choice C is the most appropriate implementation. <br><br>Note that the question asks for the "most appropriate" implementation, and not merely a legal implementation. While implementing the equals() and hashCode() methods in your class, you should only consider significant variables from that class in these methods. <br><br>The variable, which can be computed from the other variables of the class, should not be included in the implementation of these methods. Want to know more? <br><br>Besides API documentation, you can read more about the equals and hashCode() methods of Object class in Joshua Bloch's book "Effective Java" : Chapter 3. <br><br>It is available online at - <a href="http://developer.java.sun.com/developer/Books/effectivejava">http://developer.java.sun.com/developer/Books/effectivejava/Chapter3.pdf</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2020%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10604" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                20      </div>
      </div>
  <div class="content">
    <div class="qtext">
  You are required to store a list of songs and their respective singers, such that each song will have a singer (or singers) associated with it. Any one of these songs can be selected and played at any time. Moreover, you are also required to provide information about the last played song. <br><br>Which Java collection class is the most suitable for doing this?</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10604_50195" name="resp10604_" type="radio" value="50195">        </td>
        <td class="c1 text ">
          <label for="resp10604_50195">
            <span class="anun">a<span class="anumsep">.</span></span> java.util.ArrayList            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10604_50196" name="resp10604_" checked="checked" type="radio" value="50196">        </td>
        <td class="c1 text correct">
          <label for="resp10604_50196">
            <span class="anun">b<span class="anumsep">.</span></span> java.util.LinkedHashMap            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10604_50197" name="resp10604_" type="radio" value="50197">        </td>
        <td class="c1 text ">
          <label for="resp10604_50197">
            <span class="anun">c<span class="anumsep">.</span></span> java.util.IdentityHashMap            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10604_50198" name="resp10604_" type="radio" value="50198">        </td>
        <td class="c1 text ">
          <label for="resp10604_50198">
            <span class="anun">d<span class="anumsep">.</span></span> java.util.Hashtable            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10604_50199" name="resp10604_" type="radio" value="50199">        </td>
        <td class="c1 text ">
          <label for="resp10604_50199">
            <span class="anun">e<span class="anumsep">.</span></span> java.util.LinkedList            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice B is the correct answer.<br><br>Let's assume that the title of a song is unique.The requirement is to select a song by its title and also to map the title to the singers, so the choice of a map is ideal.The new Java class java.util.LinkedHashMap is the most appropriate class for performing the task mentioned in the question statement. This class can take care of both the requirements - <br>
<ol>
  <li>providing mapping for songs and singers, and </li>
  <li>providing information about the last played song with its Most Recently Used (MRU) cache.<br></li>
</ol>The problem statement calls for a class that will provide key-value (song-singer(s)) mapping. This requirement can be taken care of by any general purpose Map implementation, but there is an additional requirement that you need to provide information about the last played song. This can be achieved by using the java.util.LinkedHashMap class, which allows iteration through its entries in the order in which they were last accessed, from least-recently accessed to most-recently (access-order).<br><br> Choices C and D are incorrect because even though Hashtable (legacy class, synchronized) and HashMap are Map implementations, they do not maintain entries in access order. Thus they are not suitable for providing information about the last played song. <br><br>Choices A and E are incorrect because the ArrayList and the LinkedList classes are both List implementations and they do not have key-value storage. <br><br>The java.util.LinkedHashMap class, by default, maintains the entries in the order in which they were inserted, but it also provides a special constructor that allows you to specify that the entries should be maintained in the order in which they were last accessed, from least-recently accessed to most-recently accessed. <br><br>The constructor is - <br>public LinkedHashMap(int initialCapacity, float loadFactor, boolean accessOrder) <br><br>The last parameter accessOrder specifies the way the entries will be maintained. If accessOrder is true, the entries (key-value pairs) will be maintained in an order in which they were last accessed. If accessOrder is false, the entries will be maintained in the order in which they were inserted.<br><br> This is what API documentation says - <br><br>"A special constructor is provided to create a linked hash map whose order of iteration is the order in which its entries were last accessed, from least-recently accessed to most-recently (access-order). This kind of map is well-suited to building LRU caches. Invoking the put() or get() method results in an access to the corresponding entry (assuming it exists after the invocation completes). The putAll() method generates one entry access for each mapping in the specified map, in the order that key-value mappings are provided by the specified map's entry set iterator. No other methods generate entry accesses. In particular, operations on collection-views do not affect the order of iteration of the backing map."<br><br>"The example below illustrates how this problem can be solved with the help of the java.util.LinkedHashMap class".<br> <br>import java.util.LinkedHashMap;<br> public class JukeBox<br> { <br>
<div style="margin-left: 40px;">public static void main(String[] args)<br></div>
<div style="margin-left: 80px;"> {<br> </div>
<div style="margin-left: 120px;"> // access order LinkedHashMap <br> </div>
<div style="margin-left: 120px;">LinkedHashMap songList = new LinkedHashMap(16,0.75F,true); <br> songList.put("Stoney", "Lobo");<br> songList.put("Yesterday", "Beatles");<br> songList.put("Money", "Pink Floyd");<br> songList.put("Hotel California", "Eagles"); <br>songList.put("Lonely is the night", "Air Supply"); <br>songList.put("Walk of life", "Dire Straits"); <br> <br> // more songs.... <br> // get the song and play it <br> <br> songList.get("Walk of life");<br> songList.get("Money"); <br>songList.get("Yesterday"); <br> <br> // observe the sequence of the entries <br>// Most recently accessed entry will be the last entry <br><br> System.out.println(songList);<br></div>
<div style="margin-left: 80px;"> }<br></div> } <br><br>Want to know more? You can read more about the new collection class LinkedHashMap and its usage at - <a href="http://www-106.ibm.com/developerworks/java/library/j-mer0821/">http://www-106.ibm.com/developerworks/java/library/j-mer0821/</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2021%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10605" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                21      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the following code? <br><br>Vector&lt;Double&gt; x = new Vector&lt;Double&gt;(); <br>Vector&lt;Integer&gt; y = new Vector&lt;Integer&gt;(); <br>System.out.print(x.getClass()== y.getClass()); <br>System.out.print(x.equals( y ) );</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10605_50200" name="resp10605_" type="radio" value="50200">        </td>
        <td class="c1 text ">
          <label for="resp10605_50200">
            <span class="anun">a<span class="anumsep">.</span></span> Does not compile            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10605_50201" name="resp10605_" type="radio" value="50201">        </td>
        <td class="c1 text ">
          <label for="resp10605_50201">
            <span class="anun">b<span class="anumsep">.</span></span> Causes an exception at runtime            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10605_50202" name="resp10605_" type="radio" value="50202">        </td>
        <td class="c1 text ">
          <label for="resp10605_50202">
            <span class="anun">c<span class="anumsep">.</span></span> Prints "falsefalse"            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10605_50203" name="resp10605_" type="radio" value="50203">        </td>
        <td class="c1 text correct">
          <label for="resp10605_50203">
            <span class="anun">d<span class="anumsep">.</span></span> Prints "truetrue"            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10605_50204" name="resp10605_" type="radio" value="50204">        </td>
        <td class="c1 text ">
          <label for="resp10605_50204">
            <span class="anun">e<span class="anumsep">.</span></span> Prints "falsetrue"            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10605_50205" name="resp10605_" checked="checked" type="radio" value="50205">        </td>
        <td class="c1 text ">
          <label for="resp10605_50205">
            <span class="anun">f<span class="anumsep">.</span></span> Prints "truefalse"            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice D is the correct answer.<br><br> All instances of a generic class have the same runtime class, regardless of their actual type parameters. So the getClass() method returns java.util.Vector for both x and y. Since no data has been added to both Vector objects, they are also meaningfully equal. So the equals method returns true here.<br><br> Check out <a href="http://java.sun.com/docs/books/tutorial/extra/generics/fineprint.html">http://java.sun.com/docs/books/tutorial/extra/generics/fineprint.html</a> for more information.      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2022%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10606" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                22      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following statements are true about compiling and running the following code? <br><br>List&lt;Integer&gt; li = new ArrayList&lt;Integer&gt;(); //line1<br> List&lt;Number&gt; ln = li; // line 2<br> ln.add(5.0); // line 3<br> li.add(6); // line 4<br> for(int i:li) // line 5<br>
<div style="margin-left: 40px;"> System.out.println(i);</div></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10606_50206" name="resp10606_" type="radio" value="50206">        </td>
        <td class="c1 text correct">
          <label for="resp10606_50206">
            <span class="anun">a<span class="anumsep">.</span></span> The code will compile if lines 2 and 3 are removed.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10606_50207" name="resp10606_" type="radio" value="50207">        </td>
        <td class="c1 text ">
          <label for="resp10606_50207">
            <span class="anun">b<span class="anumsep">.</span></span> The code will compile if lines 3 and 4 are removed.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10606_50208" name="resp10606_" type="radio" value="50208">        </td>
        <td class="c1 text ">
          <label for="resp10606_50208">
            <span class="anun">c<span class="anumsep">.</span></span> The code will compile and run, printing 5 and 6.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10606_50209" name="resp10606_" checked="checked" type="radio" value="50209">        </td>
        <td class="c1 text ">
          <label for="resp10606_50209">
            <span class="anun">d<span class="anumsep">.</span></span> The code will compile fine, but will throw an exception at runtime.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice A is the correct answer.<br><br> Though Number is the superclass of Integer, List&lt;Number&gt; is not the superclass of List&lt;Integer&gt;. So, lines 2 and 3 will not compile. <br><br>Choice B is incorrect because there is nothing wrong with line 4. The primitive int value 6 will be autoboxed to an equivalent Integer object. <br><br>Since the code will not even compile, choices C and D are incorrect.<br><br> Reference: <a href="http://java.sun.com/docs/books/tutorial/extra/generics/index.html">http://java.sun.com/docs/books/tutorial/extra/generics/index.html</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2023%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10607" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                23      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and executing the following code ? <br><br>import java.util.*;<br>class Gen&lt;T&gt; <br>{<br>
<div style="margin-left: 40px;"> T obj; <br>Gen(T o)<br>{ <br>
  <div style="margin-left: 40px;">obj=o; <br></div>}<br> T get()<br> {<br>
  <div style="margin-left: 40px;"> return obj;<br></div> } <br></div>}<br><br> class Generics20<br>{<br>
<div style="margin-left: 40px;"> public static void main(String[] args)<br>{<br>
  <div style="margin-left: 40px;"> Gen&lt;Integer&gt; i1=new Gen&lt;Integer&gt;(new Integer(18)); // line1<br> Gen&lt;Integer&gt; i2=new Gen&lt;Integer&gt;(18); //line2<br> System.out.print(i1.get()==i2.get()); //line 3<br> System.out.print(i1.get().intValue()==i2.get().intValue()); //line 4<br></div> } <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10607_50210" name="resp10607_" type="radio" value="50210">        </td>
        <td class="c1 text ">
          <label for="resp10607_50210">
            <span class="anun">a<span class="anumsep">.</span></span> Compiler error at line 1            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10607_50211" name="resp10607_" type="radio" value="50211">        </td>
        <td class="c1 text ">
          <label for="resp10607_50211">
            <span class="anun">b<span class="anumsep">.</span></span> Compiler error at line 2            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10607_50212" name="resp10607_" type="radio" value="50212">        </td>
        <td class="c1 text ">
          <label for="resp10607_50212">
            <span class="anun">c<span class="anumsep">.</span></span> Compiler error at line 4            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10607_50213" name="resp10607_" checked="checked" type="radio" value="50213">        </td>
        <td class="c1 text correct">
          <label for="resp10607_50213">
            <span class="anun">d<span class="anumsep">.</span></span> Prints false true            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10607_50214" name="resp10607_" type="radio" value="50214">        </td>
        <td class="c1 text ">
          <label for="resp10607_50214">
            <span class="anun">e<span class="anumsep">.</span></span> Prints false false            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10607_50215" name="resp10607_" type="radio" value="50215">        </td>
        <td class="c1 text ">
          <label for="resp10607_50215">
            <span class="anun">f<span class="anumsep">.</span></span> Prints true true            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice D is the correct answer.<br><br> Gen is a generic class. Here, Integer is a type argument that is passed to Gen's type parameter T. <br><br>Gen&lt;Integer&gt; i2=new Gen&lt;Integer&gt;(18);<br><br> In the above statement, autoboxing is used to encapsulate the value 18. So this is equivalent to the following statement: <br><br>Gen&lt;Integer&gt; i1=new Gen&lt;Integer&gt;(new Integer(18));<br><br> So there are no compiler errors in these statements. In line 3, we are comparing the object references returned by the get() method calls. Thus, the result is false. <br><br>Line 4 compares the int values encapsulated by the 2 Integer objects. Since both values are 18, the result is true. So choice D is correct.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2024%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10608" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                24      </div>
      </div>
  <div class="content">
    <div class="qtext">
  If the print statement at line 6 of the following code prints: <br><br>Java : Hash Code = 2301506 <br><br>What will the print statement at line 8 print during the same execution of the code? <br><br>1. public class HashCodeTest <br>2. { <br>3. public static void main(String[] args) <br>4. { <br>5. String str = "Java"; <br>6. System.out.println(str+" : Hash Code = "+str.hashCode());<br> 7. makeUpper(str); <br>8. System.out.println(str+" : Hash Code = "+str.hashCode()); <br>9. } <br>10. <br>11. public static void makeUpper(String s) <br>12. { <br>13. s = s.toUpperCase(); <br>14. } <br>15. }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10608_50216" name="resp10608_" type="radio" value="50216">        </td>
        <td class="c1 text ">
          <label for="resp10608_50216">
            <span class="anun">a<span class="anumsep">.</span></span> Compilation error            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10608_50217" name="resp10608_" type="radio" value="50217">        </td>
        <td class="c1 text ">
          <label for="resp10608_50217">
            <span class="anun">b<span class="anumsep">.</span></span> The output can not be determined            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10608_50218" name="resp10608_" type="radio" value="50218">        </td>
        <td class="c1 text ">
          <label for="resp10608_50218">
            <span class="anun">c<span class="anumsep">.</span></span> It will print - JAVA : Hash Code = followed by a number other than 2301506            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10608_50219" name="resp10608_" checked="checked" type="radio" value="50219">        </td>
        <td class="c1 text correct">
          <label for="resp10608_50219">
            <span class="anun">d<span class="anumsep">.</span></span> It will print - Java : Hash Code = 2301506            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10608_50220" name="resp10608_" type="radio" value="50220">        </td>
        <td class="c1 text ">
          <label for="resp10608_50220">
            <span class="anun">e<span class="anumsep">.</span></span> It will print - JAVA : Hash Code = 2301506            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10608_50221" name="resp10608_" type="radio" value="50221">        </td>
        <td class="c1 text ">
          <label for="resp10608_50221">
            <span class="anun">f<span class="anumsep">.</span></span> It will print - Java : Hash Code = followed by a number other than 2301506            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice D is the correct answer.<br><br> There is no problem with the code and it will compile and run fine. It will print the same hash code in both the cases. <br><br>The key concept that needs to be understood here is that whenever the hashCode() method is invoked on the same object more than once during the same execution of the application, the hashCode() method consistently returns the same result, provided that the object state is not changed. <br><br>The original String "Java" is not changed here; it remains the same. Hence, both the lines 6 and 8 will print the same hash code. <br><br>Here are excerpts from API - <br><br>"Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application." <br><br>Choice A is incorrect because there is no error in the code, the main method can call another static method; this call is perfectly legal. <br><br>Also, it is important to note that the original String str is never changed in the code. <br><br>The makeUpper method changes its local copy.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2025%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q16306" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                25      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Choose the correct options.<br>(Choose three options)<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16306_62003" name="resp16306_62003" checked="checked" type="checkbox" value="62003">        </td>
        <td class="c1 text correct">
          <label for="resp16306_62003">
            <span class="anun">a<span class="anumsep">.</span></span> Can only be called from synchronized code  : wait.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16306_62004" name="resp16306_62004" checked="checked" type="checkbox" value="62004">        </td>
        <td class="c1 text correct">
          <label for="resp16306_62004">
            <span class="anun">b<span class="anumsep">.</span></span> Waits for a thread to die  : join.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16306_62005" name="resp16306_62005" checked="checked" type="checkbox" value="62005">        </td>
        <td class="c1 text correct">
          <label for="resp16306_62005">
            <span class="anun">c<span class="anumsep">.</span></span> Thread temporarily ceases execution  : sleep.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16306_62006" name="resp16306_62006" type="checkbox" value="62006">        </td>
        <td class="c1 text ">
          <label for="resp16306_62006">
            <span class="anun">d<span class="anumsep">.</span></span> Called by JVM when the thread gets CPU access : start.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        ANSWER : A, B, C <br><br>Explanation:<br>The wait method is called only from synchronized code, by a thread, to temporarily release the lock of an object, so that the other threads can enter the code. The join method causes the current thread to wait, till the thread on which the method is invoked completes its execution (dies). <br><br>The sleep method causes the current thread to temporarily cease execution (sleep) for the given time. The start method is called to cause the thread to start execution, that is, it puts the thread in the runnable state. The JVM calls the run method of the thread when CPU access is given to the thread.<br><br>Reference:<br><a href="http://java.sun.com/docs/books/tutorial/essential/threads/" target="_blank">http://java.sun.com/docs/books/tutorial/essential/threads/ </a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2026%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10609" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                26      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and executing the following code? <br><br>public class ThreadTest extends Thread <br>{ <br>
<div style="margin-left: 40px;">public void run() <br>{ <br>
  <div style="margin-left: 40px;">System.out.println("In run"); <br>yield();<br> System.out.println("Leaving run"); <br></div>}<br> public static void main(String[] args) <br>{ <br>
  <div style="margin-left: 40px;">(new ThreadTest()).start(); <br></div>}<br></div> }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10609_50222" name="resp10609_" type="radio" value="50222">        </td>
        <td class="c1 text ">
          <label for="resp10609_50222">
            <span class="anun">a<span class="anumsep">.</span></span> The code fails to compile in the main() method.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10609_50223" name="resp10609_" type="radio" value="50223">        </td>
        <td class="c1 text ">
          <label for="resp10609_50223">
            <span class="anun">b<span class="anumsep">.</span></span> The code fails to compile in the run() method.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10609_50224" name="resp10609_" type="radio" value="50224">        </td>
        <td class="c1 text ">
          <label for="resp10609_50224">
            <span class="anun">c<span class="anumsep">.</span></span> Only the text "In run" will be displayed.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10609_50225" name="resp10609_" checked="checked" type="radio" value="50225">        </td>
        <td class="c1 text correct">
          <label for="resp10609_50225">
            <span class="anun">d<span class="anumsep">.</span></span> The text "In run" followed by "Leaving run" will be displayed.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10609_50226" name="resp10609_" type="radio" value="50226">        </td>
        <td class="c1 text ">
          <label for="resp10609_50226">
            <span class="anun">e<span class="anumsep">.</span></span> The code compiles correctly but nothing is displayed.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice D is the correct answer.<br><br> Choice A is incorrect. <br><br>The main() method is defined correctly, and the line (new ThreadTest()).start(); is a valid way to create and start a ThreadTest thread (since the ThreadTest class is a subclass of the Thread class). <br><br>Choice B is incorrect as the run() method is declared correctly. <br><br>The yield() method simply returns the control back to the JVM, and unless there is a higher priority thread ready to run, this thread will continue or resume execution. <br><br>Choice C is incorrect as the yield() method only has a temporary effect on execution. <br><br>Choice E is incorrect as the start() method starts the thread. On doing so, it is the run() method which is executed. Therefore, the text is displayed.<br><br> Reference: <a href="http://java.sun.com/docs/books/tutorial/essential/threads/">http://java.sun.com/docs/books/tutorial/essential/threads/</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2027%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10610" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                27      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will be the output when you compile and execute the following program? <br><br>class Threadable implements Runnable <br>{ <br>
<div style="margin-left: 40px;">public void run() <br>{ <br>
  <div style="margin-left: 40px;">for(int i = 0; i &lt; 10; i++) <br>
    <div style="margin-left: 40px;">System.out.println("Threadable: Running..");<br></div></div> }<br></div> }<br> <br>class Base extends Thread <br>{ <br>
<div style="margin-left: 40px;">public void run() <br>{ <br>
  <div style="margin-left: 40px;">for(int i = 0; i &lt; 10; i++) <br>
    <div style="margin-left: 40px;">System.out.println("Base: Running.."); <br></div></div>}<br></div>
<div style="margin-left: 40px;"> static public void main(String[] a) <br>{ <br>
  <div style="margin-left: 40px;">Threadable aFace = new Threadable(); <br>Thread aThread = new Thread(aFace);<br> aThread.start(); <br>new Base().start();<br></div> }<br></div> }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10610_50227" name="resp10610_" type="radio" value="50227">        </td>
        <td class="c1 text ">
          <label for="resp10610_50227">
            <span class="anun">a<span class="anumsep">.</span></span> Ten times "Threadable: Running.." followed by ten times  "Base: Running.." will be printed.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10610_50228" name="resp10610_" type="radio" value="50228">        </td>
        <td class="c1 text ">
          <label for="resp10610_50228">
            <span class="anun">b<span class="anumsep">.</span></span> "Threadable: Running.." will be printed ten times            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10610_50229" name="resp10610_" type="radio" value="50229">        </td>
        <td class="c1 text ">
          <label for="resp10610_50229">
            <span class="anun">c<span class="anumsep">.</span></span> "Base: Running.." will be printed ten times            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10610_50230" name="resp10610_" type="radio" value="50230">        </td>
        <td class="c1 text correct">
          <label for="resp10610_50230">
            <span class="anun">d<span class="anumsep">.</span></span> Output is platform-dependent            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10610_50231" name="resp10610_" checked="checked" type="radio" value="50231">        </td>
        <td class="c1 text ">
          <label for="resp10610_50231">
            <span class="anun">e<span class="anumsep">.</span></span> Compiler Error            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice D is the correct answer.<br><br> Calling thread's start() method doesn't immediately cause the thread to run; it makes the thread eligible to run. The thread must contend for CPU time with all the other threads. <br><br>There are two kind of thread scheduling algorithms: <br>
<ul>
  <li>Preemptive scheduling - Depending on the priority, a thread will get the chance to execute. A higher priority thread will preempt.</li>
  <li>Round robin or Time-sliced scheduling - Each thread is allowed to execute for a limited amount of time. <br></li>
</ul>Which scheduling algorithm will be used, depends upon the operating system. Thus in the above case, choice D will be the correct answer. <br><br>Reference: <a href="http://java.sun.com/docs/books/tutorial/essential/threads/">http://java.sun.com/docs/books/tutorial/essential/threads/</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2028%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10611" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                28      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will be the result of compiling and executing the following code ? <br><br>class Thread1 extends Thread <br>{ <br>
<div style="margin-left: 40px;">public void start() <br>{ <br>
  <div style="margin-left: 40px;">super.start(); <br></div>}<br> public void run() <br>{ <br>
  <div style="margin-left: 40px;">while(true) <br></div>
  <div style="margin-left: 80px;">System.out.println("Running"); <br></div>} <br>static public void main(String[] a) <br>{ <br>
  <div style="margin-left: 40px;">Thread1 anObj = new Thread1(); <br>anObj.start();<br></div> }<br></div> }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10611_50232" name="resp10611_" type="radio" value="50232">        </td>
        <td class="c1 text ">
          <label for="resp10611_50232">
            <span class="anun">a<span class="anumsep">.</span></span> Compiler error - Cannot extend Thread class since it is final.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10611_50233" name="resp10611_" type="radio" value="50233">        </td>
        <td class="c1 text ">
          <label for="resp10611_50233">
            <span class="anun">b<span class="anumsep">.</span></span> Compiler error - Cannot find the start() method in class Thread.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10611_50234" name="resp10611_" checked="checked" type="radio" value="50234">        </td>
        <td class="c1 text correct">
          <label for="resp10611_50234">
            <span class="anun">c<span class="anumsep">.</span></span> "Running" is printed in an infinite loop.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10611_50235" name="resp10611_" type="radio" value="50235">        </td>
        <td class="c1 text ">
          <label for="resp10611_50235">
            <span class="anun">d<span class="anumsep">.</span></span> No output is produced.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice C is the correct answer.<br><br> The default implementation of the start method in the Thread class causes this thread to begin execution; the Java Virtual Machine calls the run method of this thread at its own discretion. <br><br>In the run() method, the while statement is passed true and hence an infinite loop results. Thus, choice C is correct. <br><br>The Thread class is not final, so choice A is incorrect. Here, we override the start() method and call the super.start() method which invokes the start() method in the Thread class. Hence, choice B is also incorrect. <br><br>Since choice C is correct, choice D is automatically incorrect.<br><br> References: <a href="http://java.sun.com/j2se/5.0/docs/api/java/lang/Thread.html">http://java.sun.com/j2se/5.0/docs/api/java/lang/Thread.html</a> <br><a href="http://java.sun.com/docs/books/tutorial/essential/threads/lifecycle.html"><br></a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2029%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10612" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                29      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will happen if you attempt to compile and run the following code? <br><br>1. public class ThreadDemo implements Runnable <br>2. {<br> 3. private int count = 1; <br>4. <br>5. public synchronized void doSomething() <br>6. { <br>7. for(int i=0; i &lt; 10; i++) <br>8. System.out.println(count++); <br>9. } <br>10. <br>11. public void run() <br>12. { <br>13. doSomething(); <br>14. } <br>15. <br>16. public static void main(String[] args) <br>17. { <br>18. ThreadDemo demo1 = new ThreadDemo(); <br>19. ThreadDemo demo2 = new ThreadDemo(); <br>20. Thread th1 = new Thread(demo1); <br>21. Thread th2 = new Thread(demo2); <br>22. th1.start(); <br>23. th2.start(); <br>24. } <br>25. }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10612_50236" name="resp10612_" type="radio" value="50236">        </td>
        <td class="c1 text ">
          <label for="resp10612_50236">
            <span class="anun">a<span class="anumsep">.</span></span> It will print the numbers 1 to 20 sequentially.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10612_50237" name="resp10612_" type="radio" value="50237">        </td>
        <td class="c1 text ">
          <label for="resp10612_50237">
            <span class="anun">b<span class="anumsep">.</span></span> It will print the numbers 1 to 20 but the order cannot be determined.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10612_50238" name="resp10612_" type="radio" value="50238">        </td>
        <td class="c1 text ">
          <label for="resp10612_50238">
            <span class="anun">c<span class="anumsep">.</span></span> It will print the numbers 1 to 10 sequentially two times.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10612_50239" name="resp10612_" checked="checked" type="radio" value="50239">        </td>
        <td class="c1 text correct">
          <label for="resp10612_50239">
            <span class="anun">d<span class="anumsep">.</span></span> It will print the numbers 1 to 10 two times but their order cannot be determined.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10612_50240" name="resp10612_" type="radio" value="50240">        </td>
        <td class="c1 text ">
          <label for="resp10612_50240">
            <span class="anun">e<span class="anumsep">.</span></span> The code will not compile.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice D is the correct answer.<br><br> The code will compile fine and will print the numbers 1 to 10 two times but their order cannot be determined. <br><br>Note that though the doSomething method is synchronized, the two threads do not synchronize on the same instance. The th1 and th2 threads obtain the locks on the demo1 and demo2 objects, and no synchronization takes place between these two threads. <br><br>A lock is associated with every object, and in case of a synchronized code, when one thread obtains the lock on an object, the other threads cannot obtain the lock on the same object, and must wait for the thread that has obtained the lock on the object to relinquish the lock. <br><br>In this case, the th1 thread obtains the lock on demo1, and starts executing the doSomething() method. But this does not prevent the th2 thread from obtaining the lock on demo2 and executing its code concurrently. Thus, both threads concurrently execute their codes, producing the output of the numbers 1 to 10, which might get intermixed. This will print the numbers 1 to 10 two times, but their order obviously cannot be determined. <br><br>The key lies in understanding the fact that these two threads are essentially dealing with two *distinct* objects, and not the same object. <br><br>It is very important to understand the synchronization concepts properly.<br><br> Want to know more? The following article discusses important concepts about multithreading - <a href="http://www.developerlife.com/lessons/threadsintro/default.htm">http://www.developerlife.com/lessons/threadsintro/default.htm</a><br> <a href="http://java.sun.com/docs/books/tutorial/essential/threads/multithreaded.html"><br></a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2030%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10613" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                30      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following statements regarding the notify() method are correct? Select three choices.<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10613_50241" name="resp10613_50241" checked="checked" type="checkbox" value="50241">        </td>
        <td class="c1 text correct">
          <label for="resp10613_50241">
            <span class="anun">a<span class="anumsep">.</span></span> It is an instance method of the Object class.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10613_50242" name="resp10613_50242" type="checkbox" value="50242">        </td>
        <td class="c1 text ">
          <label for="resp10613_50242">
            <span class="anun">b<span class="anumsep">.</span></span> It is a static method of the Object class.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10613_50243" name="resp10613_50243" type="checkbox" value="50243">        </td>
        <td class="c1 text ">
          <label for="resp10613_50243">
            <span class="anun">c<span class="anumsep">.</span></span> It is an instance method of the Thread class.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10613_50244" name="resp10613_50244" checked="checked" type="checkbox" value="50244">        </td>
        <td class="c1 text correct">
          <label for="resp10613_50244">
            <span class="anun">d<span class="anumsep">.</span></span> The current thread must have a lock on the object on which the notify method is invoked.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10613_50245" name="resp10613_50245" type="checkbox" value="50245">        </td>
        <td class="c1 text ">
          <label for="resp10613_50245">
            <span class="anun">e<span class="anumsep">.</span></span> If there are multiple threads waiting, you can indicate the thread to be notified.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10613_50246" name="resp10613_50246" checked="checked" type="checkbox" value="50246">        </td>
        <td class="c1 text correct">
          <label for="resp10613_50246">
            <span class="anun">f<span class="anumsep">.</span></span> It must be called from synchronized code.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices A, D, and F are the correct answers.<br><br> The notify method is an instance (non-static) method of the Object class. Thus choices B and C are incorrect. <br><br>The Thread must have a lock on the object on which the notify method is to be invoked, otherwise IllegalMonitorStateException is thrown. <br><br>The wait and notify methods must be called from the synchronized code just because the lock of an object is available only from within the synchronized code. <br><br>Choice E is incorrect as you cannot specify which thread is to be notified, if there are multiple threads in the waiting state. <br><br>The thread scheduler uses its own discretion to choose a thread from the set of waiting threads.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2031%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10614" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                31      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following statements about the given piece of code are true? <br><br>class Test implements Runnable <br>{ <br>
<div style="margin-left: 40px;">public static void main(String [] args) <br>{ <br>
  <div style="margin-left: 40px;">Thread t = new Thread(new Test()); <br>t.start(); <br></div>} <br>public void run(int limit) <br>{ <br>
  <div style="margin-left: 40px;">for (int x = 0; x &lt; limit; x++) <br>
    <div style="margin-left: 40px;">System.out.println(x); <br></div></div>}<br></div> }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10614_50247" name="resp10614_" type="radio" value="50247">        </td>
        <td class="c1 text ">
          <label for="resp10614_50247">
            <span class="anun">a<span class="anumsep">.</span></span> All the numbers up to (but not including) "limit" are printed out.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10614_50248" name="resp10614_" type="radio" value="50248">        </td>
        <td class="c1 text ">
          <label for="resp10614_50248">
            <span class="anun">b<span class="anumsep">.</span></span> Nothing is displayed. There is no explicit call to the run() method.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10614_50249" name="resp10614_" checked="checked" type="radio" value="50249">        </td>
        <td class="c1 text correct">
          <label for="resp10614_50249">
            <span class="anun">c<span class="anumsep">.</span></span> The code fails to compile because the Runnable interface is not implemented correctly.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10614_50250" name="resp10614_" type="radio" value="50250">        </td>
        <td class="c1 text ">
          <label for="resp10614_50250">
            <span class="anun">d<span class="anumsep">.</span></span> The code can be made to compile by declaring the Test class to be abstract.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10614_50251" name="resp10614_" type="radio" value="50251">        </td>
        <td class="c1 text ">
          <label for="resp10614_50251">
            <span class="anun">e<span class="anumsep">.</span></span> The code can be made to compile by removing the words "implements Runnable".            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice C is the correct answer.<br><br> The signature for the run() method is public void run(). <br><br>As presented in the question, the compiler interprets the run(int) method as simply another method in the class, and assumes that the Runnable interface is not correctly implemented. <br><br>Choices D and E are incorrect because the Test class will not compile whether it is declared abstract or with the run() method removed, because the invocation Thread t = new Thread(new Test()) will cause compilation to fail then. This is because this constructor of the Thread class takes a Runnable object as the argument. <br><br>Choices A and B are incorrect since the code does not compile.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2032%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q16307" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                32      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Choose the correct order of the statements.</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16307_62007" name="resp16307_" type="radio" value="62007">        </td>
        <td class="c1 text ">
          <label for="resp16307_62007">
            <span class="anun">a<span class="anumsep">.</span></span> class A{ } <br>import java.util.*; <br>package p1;            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16307_62008" name="resp16307_" checked="checked" type="radio" value="62008">        </td>
        <td class="c1 text correct">
          <label for="resp16307_62008">
            <span class="anun">b<span class="anumsep">.</span></span> package p1; <br>import java.util.*;<br> class A{ }            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16307_62009" name="resp16307_" type="radio" value="62009">        </td>
        <td class="c1 text ">
          <label for="resp16307_62009">
            <span class="anun">c<span class="anumsep">.</span></span> import java.util.*; <br>package p1; <br>class A{ }            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        ANSWER : B <br><br>Explanation:<br>In a Java source file, the package statement must be the first statement. It declares that all the classes that are defined in the compilation unit belong to this package. If no package statement is defined, the classes belong to the default unnamed package. Import statements are used to import parts of a package namespace into the local scope of a Java class. If any import statements are to be included, they must be inserted after the package statement, but before any class declarations.<br><br>References:<br><a href="http://java.sun.com/docs/books/tutorial/java/interpack/createpkgs.html" target="_blank">http://java.sun.com/docs/books/tutorial/java/interpack/createpkgs.html</a><br><a target="_blank" href="http://java.sun.com/docs/books/tutorial/java/interpack/usepkgs.html">http://java.sun.com/docs/books/tutorial/java/interpack/usepkgs.html </a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2033%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q16308" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                33      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the output when the following code is run.<br><br>public class NestedClassTest <br>{ <br>public void print() <br>{ <br>System.out.print("From Enclosing "); <br>} <br>public class Inner <br>{ <br>public void print() <br>{ <br>System.out.print("From Inner "); <br>} <br>public void printAll() <br>{ <br> this.print(); <br> NestedClassTest.this.print(); <br>} <br>} <br>public static void main(String[] args) <br>{ <br> NestedClassTest.Inner i = new NestedClassTest().new Inner();<br>i.printAll(); <br>} <br>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16308_62010" name="resp16308_" checked="checked" type="radio" value="62010">        </td>
        <td class="c1 text correct">
          <label for="resp16308_62010">
            <span class="anun">a<span class="anumsep">.</span></span> From Inner From Enclosing.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16308_62011" name="resp16308_" type="radio" value="62011">        </td>
        <td class="c1 text ">
          <label for="resp16308_62011">
            <span class="anun">b<span class="anumsep">.</span></span> Compilation error.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16308_62012" name="resp16308_" type="radio" value="62012">        </td>
        <td class="c1 text ">
          <label for="resp16308_62012">
            <span class="anun">c<span class="anumsep">.</span></span> From Inner From Inner.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16308_62013" name="resp16308_" type="radio" value="62013">        </td>
        <td class="c1 text ">
          <label for="resp16308_62013">
            <span class="anun">d<span class="anumsep">.</span></span> From Enclosing From Enclosing.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        ANSWER : A<br><br>Explanation:<br>A non-static inner class instance can only exist with an instance of its enclosing class. To instantiate a non-static inner class from outside code, we need to use the new OuterClassName().new InnerClassName() syntax. Within an inner class code, the this reference refers to the instance of the inner class. To reference the outer class instance from within the inner class code, use &lt;OuterClassName&gt;.this<br><br>Here, we invoke the print methods in the enclosed and enclosing classes using this and NestedClassTest.this references.<br><br>Read more about inner classes at<br><a href="http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.1.3" target="_blank">http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.1.3</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2034%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q16309" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                34      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Consider the following definitions and choose the option that compiles fine.<br><br>interface Inter1 <br>{ <br>void f1(); <br>}<br>interface Inter2 <br>{ <br>void f2(); <br>} <br>class A <br>{ <br>protected void g(){} <br>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16309_62014" name="resp16309_" type="radio" value="62014">        </td>
        <td class="c1 text correct">
          <label for="resp16309_62014">
            <span class="anun">a<span class="anumsep">.</span></span> class Test  extends A, implements Inter1, Inter2 <br>      { <br>  public void f1(){} <br><br>   public void f2() throws RuntimeException{} <br><br>   protected void g(){ } <br> }            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16309_62015" name="resp16309_" type="radio" value="62015">        </td>
        <td class="c1 text ">
          <label for="resp16309_62015">
            <span class="anun">b<span class="anumsep">.</span></span> class Test  implements Inter1, Inter2 extends A <br>      { <br>  public void f1(){} <br><br>   public void f2() throws RuntimeException{} <br><br>   protected void g(){ } <br> }            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16309_62016" name="resp16309_" type="radio" value="62016">        </td>
        <td class="c1 text ">
          <label for="resp16309_62016">
            <span class="anun">c<span class="anumsep">.</span></span> class Test  extends A, implements Inter1, Inter2  <br>     { <br>  public void f1(){} <br><br>   public void f2() throws RuntimeException{} <br><br>   void g(){ } <br> }             <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16309_62017" name="resp16309_" type="radio" value="62017">        </td>
        <td class="c1 text ">
          <label for="resp16309_62017">
            <span class="anun">d<span class="anumsep">.</span></span> class Test  extends A, implements Inter1, Inter2   <br>    { <br>  void f1(){} <br><br>   void f2() throws RuntimeException{} <br><br>   protected void g(){ } <br> }             <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16309_62018" name="resp16309_" checked="checked" type="radio" value="62018">        </td>
        <td class="c1 text ">
          <label for="resp16309_62018">
            <span class="anun">e<span class="anumsep">.</span></span> None of the above.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        ANSWER : A<br><br>When a class extends another class and also implements one or more interfaces, the extends keyword is used first, followed by implements. The interface names are separated by commas. <br><br>Interface methods are implicitly public, so they can be redefined as public only, in the implementing class. So, the f1() and f2() methods should be public in the Test class. <br><br>The f2() method can only throw unchecked exceptions, since the method declaration in the Inter2 interface does not throw any checked exceptions. Thus, the method can throw RuntimeException. <br><br>The g() method is defined as protected in the A class, so the overridding method g() in the Test class must also be protected (or of public access), as an overridden method cannot be more public than the overriding method.<br><br>Reference:<br><a target="_blank" href="http://java.sun.com/docs/books/jls/third_edition/html/names.html#6.4.4">http://java.sun.com/docs/books/jls/third_edition/html/names.html#6.4.4 </a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2035%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q16310" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                35      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which is the correct class that extends from following class.<br>class A<br>{ <br>Number n= new Integer(5); <br>Double d=9.0; <br>Number getValue(){return null;} <br>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16310_62019" name="resp16310_" type="radio" value="62019">        </td>
        <td class="c1 text ">
          <label for="resp16310_62019">
            <span class="anun">a<span class="anumsep">.</span></span> class B extends A<br> { <br>  Object getValue(){return  "abc";} <br> }            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16310_62020" name="resp16310_" type="radio" value="62020">        </td>
        <td class="c1 text ">
          <label for="resp16310_62020">
            <span class="anun">b<span class="anumsep">.</span></span> class B extends A<br> { <br>  Object getValue(){return  2;} <br> }            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16310_62021" name="resp16310_" checked="checked" type="radio" value="62021">        </td>
        <td class="c1 text correct">
          <label for="resp16310_62021">
            <span class="anun">c<span class="anumsep">.</span></span> class B extends A<br> { <br>  Integer getValue(){return  3;} <br> }            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16310_62022" name="resp16310_" type="radio" value="62022">        </td>
        <td class="c1 text ">
          <label for="resp16310_62022">
            <span class="anun">d<span class="anumsep">.</span></span> None of the above.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        ANSWER : C<br><br>"Covariant return types" is a new feature that allows you to use the subclass of the return type of the overridden method, as the return type for the overriding method. So the getValue() method in class A returns Number, in class B it can return a Number or anything extending from Number <br><br>To know more about the covariant return types feature, refer to<br><a href="http://java.sun.com/developer/JDCTechTips/2004/tt1201.html" target="_blank">http://java.sun.com/developer/JDCTechTips/2004/tt1201.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2036%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10615" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                36      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following can be independently placed inside the child class for the code to compile correctly? Select four choices. <br><br>class Parent <br>{ <br>
<div style="margin-left: 40px;">void f(String s1) {} <br></div>}<br> abstract class Child extends Parent <br>{ <br>
<div style="margin-left: 40px;">//insert code here <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10615_50252" name="resp10615_50252" checked="checked" type="checkbox" value="50252">        </td>
        <td class="c1 text correct">
          <label for="resp10615_50252">
            <span class="anun">a<span class="anumsep">.</span></span> protected void f(String s)throws RuntimeException {}            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10615_50253" name="resp10615_50253" checked="checked" type="checkbox" value="50253">        </td>
        <td class="c1 text correct">
          <label for="resp10615_50253">
            <span class="anun">b<span class="anumsep">.</span></span> synchronized void f(String s)throws Error {}            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10615_50254" name="resp10615_50254" checked="checked" type="checkbox" value="50254">        </td>
        <td class="c1 text correct">
          <label for="resp10615_50254">
            <span class="anun">c<span class="anumsep">.</span></span> void f(boolean b) {}            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10615_50255" name="resp10615_50255" type="checkbox" value="50255">        </td>
        <td class="c1 text ">
          <label for="resp10615_50255">
            <span class="anun">d<span class="anumsep">.</span></span> int f(String s) {}            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10615_50256" name="resp10615_50256" type="checkbox" value="50256">        </td>
        <td class="c1 text ">
          <label for="resp10615_50256">
            <span class="anun">e<span class="anumsep">.</span></span> private void f(String s) {}            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10615_50257" name="resp10615_50257" checked="checked" type="checkbox" value="50257">        </td>
        <td class="c1 text correct">
          <label for="resp10615_50257">
            <span class="anun">f<span class="anumsep">.</span></span> abstract void f(String s) ;            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices A, B, C, and F are the correct answers.<br><br> Choice A is allowed because a method can be made more public when you override it, and it is allowed to throw any unchecked exceptions. <br><br>Choice B is correct because a non-synchronized method can be overridden to be synchronized; also, Error comes under the group of unchecked exceptions. <br><br>Choice C is a valid example of overloading, just by changing the arguments. <br><br>Choice D is not allowed because only the return type is changed; this is not valid overriding or overloading. <br><br>Choice E is trying to make the method more private, which is again a violation of overriding rules. <br><br>Choice F is legal because a concrete method can be overridden to be abstract.<br><br> References: <a href="http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.4.8">http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.4.8</a><br> <a href="http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.4.9">http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.4.9</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2037%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10617" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                37      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following statements about the following code are true? Select two choices. <br><br>package com.name; <br>interface XYZ <br>{<br>
<div style="margin-left: 40px;"> double a = 2; <br></div>} <br>class A{}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10617_50262" name="resp10617_50262" type="checkbox" value="50262">        </td>
        <td class="c1 text ">
          <label for="resp10617_50262">
            <span class="anun">a<span class="anumsep">.</span></span> The variable "a" can be accessed in class A only if class A implements XYZ.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10617_50263" name="resp10617_50263" checked="checked" type="checkbox" value="50263">        </td>
        <td class="c1 text correct">
          <label for="resp10617_50263">
            <span class="anun">b<span class="anumsep">.</span></span> The variable "a" can be accessed in class A by using a static import.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10617_50264" name="resp10617_50264" type="checkbox" value="50264">        </td>
        <td class="c1 text ">
          <label for="resp10617_50264">
            <span class="anun">c<span class="anumsep">.</span></span> The variable "a" can be modified in class A.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10617_50265" name="resp10617_50265" checked="checked" type="checkbox" value="50265">        </td>
        <td class="c1 text correct">
          <label for="resp10617_50265">
            <span class="anun">d<span class="anumsep">.</span></span> The variable "a" cannot be modified in class A.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices B and D are the correct answers.<br><br> The variables declared in an interface are implicitly public, static, and final. The static import feature enables you to import static members from a class or an interface. So we can statically import the members of the interface XYZ by using the statement - import static com.name.XYZ.* <br><br>However, this variable's value cannot be modified in the class because the variable is final. So choice C is incorrect. <br><br>Before the feature of static imports was introduced, a class had to implement an interface to access its members. However, this is no longer true, so choice A is now incorrect. <be><br><br>To know more about static imports, refer to <br><a href="http://java.sun.com/docs/books/jls/third_edition/html/packages.html#7.5.3">http://java.sun.com/docs/books/jls/third_edition/html/packages.html#7.5.3</a><br> <a href="http://java.sun.com/j2se/1.5.0/docs/guide/language/static-import.html">http://java.sun.com/j2se/1.5.0/docs/guide/language/static-import.html</a></be>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2038%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10618" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                38      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following are the valid ways to define a constructor for class Test? Select two choices.<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10618_50266" name="resp10618_50266" type="checkbox" value="50266">        </td>
        <td class="c1 text ">
          <label for="resp10618_50266">
            <span class="anun">a<span class="anumsep">.</span></span> public void Test(){}            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10618_50267" name="resp10618_50267" checked="checked" type="checkbox" value="50267">        </td>
        <td class="c1 text correct">
          <label for="resp10618_50267">
            <span class="anun">b<span class="anumsep">.</span></span> public Test(){}            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10618_50268" name="resp10618_50268" checked="checked" type="checkbox" value="50268">        </td>
        <td class="c1 text correct">
          <label for="resp10618_50268">
            <span class="anun">c<span class="anumsep">.</span></span> private Test(){}            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10618_50269" name="resp10618_50269" type="checkbox" value="50269">        </td>
        <td class="c1 text ">
          <label for="resp10618_50269">
            <span class="anun">d<span class="anumsep">.</span></span> public static Test(){}            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10618_50270" name="resp10618_50270" type="checkbox" value="50270">        </td>
        <td class="c1 text ">
          <label for="resp10618_50270">
            <span class="anun">e<span class="anumsep">.</span></span> final Test(){}            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices B and C are the correct answers.<br><br> Choice A is incorrect because the presence of the void keyword indicates that Test() is actually a method (constructors do not have a return type, not even void). <br><br>Choice D is incorrect because constructors cannot be static. <br><br>Choice E is incorrect because constructors cannot be final. In general, constructors cannot be:<br>
<ul>
  <li> native</li>
  <li>final</li>
  <li>static</li>
  <li>synchronized </li>
  <li>abstract<br></li>
</ul> References: <a href="http://www.javaworld.com/jw-10-2000/jw-1013-constructors.html">http://www.javaworld.com/jw-10-2000/jw-1013-constructors.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2039%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10619" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                39      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the following code? <br><br>class Vararg6 <br>{<br>
<div style="margin-left: 40px">public static void main(String[] args)<br>{<br>
  <div style="margin-left: 40px">callMe(5); // line 1 <br>callMe(); // line 2 <br></div>}<br>static void callMe(byte b)<br>{ <br>
  <div style="margin-left: 40px">System.out.print("byte"); <br></div>}<br>static void callMe(int... b)<br>{<br>
  <div style="margin-left: 40px">System.out.print("int"); <br></div>}<br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10619_50271" name="resp10619_" type="radio" value="50271">        </td>
        <td class="c1 text ">
          <label for="resp10619_50271">
            <span class="anun">a<span class="anumsep">.</span></span> Compiler error at line 1            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10619_50272" name="resp10619_" type="radio" value="50272">        </td>
        <td class="c1 text ">
          <label for="resp10619_50272">
            <span class="anun">b<span class="anumsep">.</span></span> Compiler error at line 2            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10619_50273" name="resp10619_" checked="checked" type="radio" value="50273">        </td>
        <td class="c1 text ">
          <label for="resp10619_50273">
            <span class="anun">c<span class="anumsep">.</span></span> Prints byteint            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10619_50274" name="resp10619_" type="radio" value="50274">        </td>
        <td class="c1 text correct">
          <label for="resp10619_50274">
            <span class="anun">d<span class="anumsep">.</span></span> Prints intint            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice D is the correct answer.<br><br>The variable arguments (varargs) feature allows a method to be called with zero or more arguments. <br><br>Here the callMe(int... b) method declares b as a variable argument. So it can be invoked by any of the following calls. <br><br>
<div style="margin-left: 40px">callMe() <br>callMe(x1,x2....xn) // where x1, x2, ...xn are of type int <br>callMe(x) // where x is of type int or int[]<br></div><br>Here, we have a callMe method that takes a byte argument also. When we invoke callMe(5), this method is not called because the default type of 5 is taken as int. <br><br>So both calls in the code will cause the varargs version to be invoked. Thus, the output is "intint".<br><br>Reference: <a href="http://java.sun.com/j2se/1.5.0/docs/guide/language/varargs.html">http://java.sun.com/j2se/1.5.0/docs/guide/language/varargs.html</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2040%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10620" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                40      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following statements about the nested classes are true? Select two choices.<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10620_50275" name="resp10620_50275" type="checkbox" value="50275">        </td>
        <td class="c1 text ">
          <label for="resp10620_50275">
            <span class="anun">a<span class="anumsep">.</span></span> Nested classes cannot be marked private.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10620_50276" name="resp10620_50276" checked="checked" type="checkbox" value="50276">        </td>
        <td class="c1 text correct">
          <label for="resp10620_50276">
            <span class="anun">b<span class="anumsep">.</span></span> An instance of a static nested class can be created without an instance of its enclosing class.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10620_50277" name="resp10620_50277" type="checkbox" value="50277">        </td>
        <td class="c1 text ">
          <label for="resp10620_50277">
            <span class="anun">c<span class="anumsep">.</span></span> A source file containing a nested class will produce only one .class output file.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10620_50278" name="resp10620_50278" checked="checked" type="checkbox" value="50278">        </td>
        <td class="c1 text correct">
          <label for="resp10620_50278">
            <span class="anun">d<span class="anumsep">.</span></span> To create an instance of a non-static nested class, an instance of its enclosing class is required.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices B and D are the correct answers.<br><br> Choice A is incorrect as a nested class can have any kind of access modifier, private included. <br><br>Choice C is incorrect as a nested class is put into its own .class output file, using the file name Outer$nested.class, so there will be two class files per source file. <br><br>A static nested class does not require an instance of the enclosing class. For instantiating a non-static nested class, an instance of its enclosing class is required.<br><br> More about nested classes is available at <a href="http://java.sun.com/docs/books/tutorial/java/javaOO/nested.html">http://java.sun.com/docs/books/tutorial/java/javaOO/nested.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2041%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q16311" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                41      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the output when the following code is run ?<br><br>class MultiDim<br>{ <br>public static void main(String[] args)<br>{ <br>String[][] s={{"ab","cd"},{"12","3","4"}}; <br><br>for(String[] obj : s) <br><br>for(String str : obj) <br><br>System.out.println(str); <br>} <br>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16311_62023" name="resp16311_" type="radio" value="62023">        </td>
        <td class="c1 text ">
          <label for="resp16311_62023">
            <span class="anun">a<span class="anumsep">.</span></span> Compilation error.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16311_62024" name="resp16311_" checked="checked" type="radio" value="62024">        </td>
        <td class="c1 text correct">
          <label for="resp16311_62024">
            <span class="anun">b<span class="anumsep">.</span></span> ab<br> cd<br> 12<br> 3<br> 4            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16311_62025" name="resp16311_" type="radio" value="62025">        </td>
        <td class="c1 text ">
          <label for="resp16311_62025">
            <span class="anun">c<span class="anumsep">.</span></span> Exception at runtime.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16311_62026" name="resp16311_" type="radio" value="62026">        </td>
        <td class="c1 text ">
          <label for="resp16311_62026">
            <span class="anun">d<span class="anumsep">.</span></span> 12<br> 3<br> 4            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        ANSWER : B<br><br>Multidimensional arrays consist of arrays of arrays. In each iteration of the array, the elements retrieved are arrays themselves. So we need nested for loops to retrieve the individual elements. <br><br>Here, the outer for loop iterates over the array s and retrieves the member String[] arrays using the reference variable obj. The inner loop then iterates over the arrays contained in obj and the individual String object elements are printed out.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2042%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10622" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                42      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following code snippets will compile correctly? (Assume that the code is compiled and run with assertions enabled) Select three choices.<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10622_50283" name="resp10622_50283" type="checkbox" value="50283">        </td>
        <td class="c1 text ">
          <label for="resp10622_50283">
            <span class="anun">a<span class="anumsep">.</span></span> Object obj = null; <br> &nbsp;&nbsp;&nbsp;&nbsp;assert (obj != null)            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10622_50284" name="resp10622_50284" type="checkbox" value="50284">        </td>
        <td class="c1 text ">
          <label for="resp10622_50284">
            <span class="anun">b<span class="anumsep">.</span></span> int i = 0; <br> &nbsp;&nbsp;&nbsp;&nbsp;assert i = 5 : "Incorrect value";            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10622_50285" name="resp10622_50285" checked="checked" type="checkbox" value="50285">        </td>
        <td class="c1 text correct">
          <label for="resp10622_50285">
            <span class="anun">c<span class="anumsep">.</span></span> boolean b = false; <br> &nbsp;&nbsp;&nbsp;&nbsp;assert b = true;            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10622_50286" name="resp10622_50286" checked="checked" type="checkbox" value="50286">        </td>
        <td class="c1 text correct">
          <label for="resp10622_50286">
            <span class="anun">d<span class="anumsep">.</span></span> Object obj = null; <br> &nbsp;&nbsp;&nbsp;&nbsp;assert false : obj;            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10622_50287" name="resp10622_50287" checked="checked" type="checkbox" value="50287">        </td>
        <td class="c1 text correct">
          <label for="resp10622_50287">
            <span class="anun">e<span class="anumsep">.</span></span> assert false : null;            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices C, D, E and F are correct.<br><br> There are two forms of an assert statement - <br><br>
<div style="margin-left: 40px;">assert Expression1; <br>assert Expression1 : Expression2; <br></div><br>In both these cases, Expression1 must be a boolean expression or a compile time error will occur. An object of class java.lang.Boolean is also allowed instead of the primitive boolean, because it will be converted to boolean by autoboxing. <br><br>The Expression2 must be an expression, a method call to a method that returns void is not allowed here. However, Expression2 could be a method call to any other method that returns anything except a void. <br><br>Option A will not compile because the semicolon is missing at the end. In option B, "i = 5" is an expression of type int, and not boolean; hence it will not compile. <br><br>Option D will compile fine, because it is a valid assert statement. In option E, Expression1 is "b", which is an object of class Boolean, this is allowed and hence compiles correctly. <br><br>Option C expression "b = true" is perfectly valid because it is an expression of type boolean where true is assigned to the boolean primitive b; the value of this expression is always true. <br><br>It is useful to remember these two forms of assert as follows - <br>
<div style="margin-left: 40px;">assert boolean_condition ; <br>assert boolean_condition : secondary_expression; <br></div><br>Want to know more? <br>You can read more about assertions, its syntax and usage at - <a href="http://java.sun.com/j2se/1.4/docs/guide/lang/assert.html">http://java.sun.com/j2se/1.4/docs/guide/lang/assert.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2043%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10623" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                43      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will be the result of attempting to run the following program? <br><br>public class Test <br>{ <br>
<div style="margin-left: 40px;">public static void main(String[] args) <br>{ <br>
  <div style="margin-left: 40px;">String[][][] arr = { { {}, null }, { { "1", "2" }, { "1", null, "3" } }, {}, { { "1", null } } }; System.out.println(arr.length + arr[1][2].length); <br></div>} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10623_50288" name="resp10623_" type="radio" value="50288">        </td>
        <td class="c1 text correct">
          <label for="resp10623_50288">
            <span class="anun">a<span class="anumsep">.</span></span> ArrayIndexOutOfBoundsException is thrown.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10623_50289" name="resp10623_" type="radio" value="50289">        </td>
        <td class="c1 text ">
          <label for="resp10623_50289">
            <span class="anun">b<span class="anumsep">.</span></span> NullPointerException is thrown.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10623_50290" name="resp10623_" type="radio" value="50290">        </td>
        <td class="c1 text ">
          <label for="resp10623_50290">
            <span class="anun">c<span class="anumsep">.</span></span> 4 will be written to standard output.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10623_50291" name="resp10623_" type="radio" value="50291">        </td>
        <td class="c1 text ">
          <label for="resp10623_50291">
            <span class="anun">d<span class="anumsep">.</span></span> 6 will be written to standard output.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10623_50292" name="resp10623_" type="radio" value="50292">        </td>
        <td class="c1 text ">
          <label for="resp10623_50292">
            <span class="anun">e<span class="anumsep">.</span></span> 7 will be written to standard output.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice A is the correct answer.<br><br> The expression arr.length will evaluate to 4. <br><br>The expression arr[1] will access the element { { "1", "2" }, { "1", null, "3" } }, and the arr[1][2] expression will try to access the third sub-element of this element. <br><br>This produces an ArrayIndexOutOfBoundsException, since the element has only two sub-elements.      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2044%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10624" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                44      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will be the result of an attempt to compile and run the following code by passing a command line argument of 22? <br><br>class Test <br>{<br>
<div style="margin-left: 40px;"> public static void main(String[] args) <br>{<br>
  <div style="margin-left: 40px;"> final long c=20; <br>int b=Byte.parseByte(args[0]); //1 <br>switch(b) <br>{<br>
    <div style="margin-left: 40px;"> case (int)c://2 <br>{<br>
      <div style="margin-left: 40px;">System.out.println("1");<br> break; <br></div>}<br> case (byte)c+2: //3 <br>{<br>
      <div style="margin-left: 40px;">System.out.println("2"); <br>break; <br></div>}<br> default: System.out.println("default");<br></div> }<br></div> }<br></div> }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10624_50293" name="resp10624_" type="radio" value="50293">        </td>
        <td class="c1 text ">
          <label for="resp10624_50293">
            <span class="anun">a<span class="anumsep">.</span></span> Compiler error at line 1            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10624_50294" name="resp10624_" type="radio" value="50294">        </td>
        <td class="c1 text ">
          <label for="resp10624_50294">
            <span class="anun">b<span class="anumsep">.</span></span> Compiler error at line 2            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10624_50295" name="resp10624_" type="radio" value="50295">        </td>
        <td class="c1 text ">
          <label for="resp10624_50295">
            <span class="anun">c<span class="anumsep">.</span></span> Compiler error at line 3            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10624_50296" name="resp10624_" checked="checked" type="radio" value="50296">        </td>
        <td class="c1 text correct">
          <label for="resp10624_50296">
            <span class="anun">d<span class="anumsep">.</span></span> Compiles and runs without errors, printing 2            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10624_50297" name="resp10624_" type="radio" value="50297">        </td>
        <td class="c1 text ">
          <label for="resp10624_50297">
            <span class="anun">e<span class="anumsep">.</span></span> None of the above            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice D is the correct answer.<br><br> There are no errors in this code, it compiles and runs fine, printing 2 when the command line argument value passed is 22. The second case matches because c+2 is 22. <br><br>Here, the switch argument is of type int, so casting long to int, and passing as a case argument is perfectly valid. So there is no error at line 2. <br><br>At line 3, c is cast to byte and 2 is added, which results in an integer. So it is also valid. Note that these are allowed only because c is a final variable; case labels should be constants that can be evaluated at compile time. <br><br>There is no error at line 1 because Byte.parseByte returns a byte value that can be assigned to an int variable.<br><br> More information is available at <a href="http://java.sun.com/docs/books/jls/third_edition/html/statements.html#14.11">http://java.sun.com/docs/books/jls/third_edition/html/statements.html#14.11</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2045%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10625" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                45      </div>
      </div>
  <div class="content">
    <div class="qtext">
  You are writing a set of classes related to cooking and have created your own exception hierarchy derived from java.lang.Exception as follows:<br><br> Exception <br>
<div style="margin-left: 40px;">+-- BadTasteException <br>
  <div style="margin-left: 40px;">+-- BitterException <br>+-- SourException <br></div></div><br>Your base class BaseCook has a method declared as follows: <br>int rateFlavor(Ingredient[] list) throws BadTasteException <br><br>A class called TexMexCook derived from BaseCook, has a method that overrides the BaseCook.rateFlavor() method. Which of the following are legal declarations of the overriding method? Select four choices.<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10625_50298" name="resp10625_50298" checked="checked" type="checkbox" value="50298">        </td>
        <td class="c1 text correct">
          <label for="resp10625_50298">
            <span class="anun">a<span class="anumsep">.</span></span> int rateFlavor(Ingredient[] list) throws BadTasteException            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10625_50299" name="resp10625_50299" type="checkbox" value="50299">        </td>
        <td class="c1 text ">
          <label for="resp10625_50299">
            <span class="anun">b<span class="anumsep">.</span></span> int rateFlavor(Ingredient[] list) throws Exception            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10625_50300" name="resp10625_50300" checked="checked" type="checkbox" value="50300">        </td>
        <td class="c1 text correct">
          <label for="resp10625_50300">
            <span class="anun">c<span class="anumsep">.</span></span> int rateFlavor(Ingredient[] list) throws BitterException            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10625_50301" name="resp10625_50301" checked="checked" type="checkbox" value="50301">        </td>
        <td class="c1 text correct">
          <label for="resp10625_50301">
            <span class="anun">d<span class="anumsep">.</span></span> int rateFlavor(Ingredient[] list)            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10625_58136" name="resp10625_58136" checked="checked" type="checkbox" value="58136">        </td>
        <td class="c1 text correct">
          <label for="resp10625_58136">
            <span class="anun">e<span class="anumsep">.</span></span> int rateFlavor(Ingredient[] list) throws BitterException, RuntimeException            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices A, C, D and E are the correct answers.<br><br> Choice A is correct because overriding methods can throw the same exception. <br><br>Choice B is incorrect because the overriding method must throw the same exception or a subclass. <br><br>Choice C is correct because the overriding method can throw an exception that is a subclass of the original. <br><br>Choice D is correct because an overriding method can always throw a RuntimeException<br><br>Choice E is correct because the overriding method need not have to throw an exception.<br><br> Learn more about overriding at <a href="http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.4.8">http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.4.8</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2046%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10626" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                46      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following expressions will cause compilation error? Select three choices.<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10626_50302" name="resp10626_50302" checked="checked" type="checkbox" value="50302">        </td>
        <td class="c1 text correct">
          <label for="resp10626_50302">
            <span class="anun">a<span class="anumsep">.</span></span> assert true : return;            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10626_50303" name="resp10626_50303" type="checkbox" value="50303">        </td>
        <td class="c1 text ">
          <label for="resp10626_50303">
            <span class="anun">b<span class="anumsep">.</span></span> assert 7 &lt; 5 : 3+4;            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10626_50304" name="resp10626_50304" checked="checked" type="checkbox" value="50304">        </td>
        <td class="c1 text correct">
          <label for="resp10626_50304">
            <span class="anun">c<span class="anumsep">.</span></span> assert 7 &gt; 5 : break;            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10626_50305" name="resp10626_50305" type="checkbox" value="50305">        </td>
        <td class="c1 text ">
          <label for="resp10626_50305">
            <span class="anun">d<span class="anumsep">.</span></span> assert false :  6 &lt;&lt; 7;            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10626_50306" name="resp10626_50306" type="checkbox" value="50306">        </td>
        <td class="c1 text ">
          <label for="resp10626_50306">
            <span class="anun">e<span class="anumsep">.</span></span> assert true &amp;&amp; false || true;            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10626_58137" name="resp10626_58137" checked="checked" type="checkbox" value="58137">        </td>
        <td class="c1 text correct">
          <label for="resp10626_58137">
            <span class="anun">f<span class="anumsep">.</span></span> assert true : System.out.println("Error");]            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices A, C and F are the correct answers.<br><br> Only these two statements will cause an error at compile time. The assert statement can take one of the following two forms - <br><br>
<div style="margin-left: 40px;">assert boolean_condition : secondary_expression; <br>assert boolean_condition; <br></div><br>It is important to understand the syntax of these two assert statements. It is required by the Java compiler that the assert condition must be of type primitive boolean. And the secondary expression on the right hand side of the colon, if present, must be a valid Java expression with a value. <br><br>If any one of these requirements is not met, it will result in a compile-time error. In choice A, "return" is not a valid expression on the right hand side of the colon; hence it will cause a compiler error. <br><br>Likewise, in choice C, "break" is not a valid expression on the right hand side of the colon; hence it will also cause a compiler error. <br><br>In choice F, "System.out.println("Error")" is not a valid expression on the right hand side of the colon; hence it will also cause a compiler error. <br><br>The other statements in choices B, D, and E are valid assert statements for the J2SE 1.4 compiler, hence none of them will cause an error at runtime.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2047%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10627" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                47      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following are the appropriate uses of assertions? Select three choices.<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10627_50307" name="resp10627_50307" checked="checked" type="checkbox" value="50307">        </td>
        <td class="c1 text correct">
          <label for="resp10627_50307">
            <span class="anun">a<span class="anumsep">.</span></span> private void doSomething(int value)<br> &nbsp;&nbsp;&nbsp;&nbsp;{<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;assert (value &gt; 0 &amp;&amp; value &lt; 1000) <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: "The value must be in the range [1 -999]"; <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// more code <br>&nbsp;&nbsp;&nbsp;&nbsp;}            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10627_50308" name="resp10627_50308" checked="checked" type="checkbox" value="50308">        </td>
        <td class="c1 text ">
          <label for="resp10627_50308">
            <span class="anun">b<span class="anumsep">.</span></span> public void doSomething(int value) <br> &nbsp;&nbsp;&nbsp;&nbsp;{<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;assert (value &gt; 0 &amp;&amp; value &lt; 1000) <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: "The value must be in the range [1 -999]"; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// more code <br>  &nbsp;&nbsp;&nbsp;&nbsp;}            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10627_50309" name="resp10627_50309" checked="checked" type="checkbox" value="50309">        </td>
        <td class="c1 text correct">
          <label for="resp10627_50309">
            <span class="anun">c<span class="anumsep">.</span></span> private int doSomething()<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// compute result<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;assert result &gt; 0 : "Incorrect result"; <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return result;<br> &nbsp;&nbsp;&nbsp;&nbsp;}            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10627_50310" name="resp10627_50310" type="checkbox" value="50310">        </td>
        <td class="c1 text correct">
          <label for="resp10627_50310">
            <span class="anun">d<span class="anumsep">.</span></span> public int doSomething()<br> &nbsp;&nbsp;&nbsp;&nbsp;{<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// compute result <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;assert result &gt; 0 : "Incorrect result";<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return result; <br>&nbsp;&nbsp;&nbsp;&nbsp;}            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices A, C, and D are the correct answers.<br><br> Assertions can be used to test preconditions, postconditions, and invariants. Java insists that assertions should not be used for testing the preconditions of the public methods. Instead, preconditions on public methods are enforced by explicit checks inside methods resulting in particular, specified exceptions. <br><br>This is essential because of the following two reasons:<br>
<ol>
  <li> Exceptions can be explicitly mentioned in the throws cause of the method, and checked exceptions must be caught while invoking the method.</li>
  <li>Assertions can be disabled while running the code. <br></li>
</ol>Hence, the code snippet given in choice B shows incorrect and improper usage of an assertion in a public method. However, testing preconditions for non-public methods is perfectly valid. <br><br>Hence choice A is a correct and proper usage of assertions. <br>As for choices C and D, both these methods use assertions for testing the postconditions. This is not only valid, but it is also highly recommended for writing solid code. <br><br>Postcondition checks are best implemented via assertions, whether or not they are specified in public methods. <br><br>Want to know more? Correct and effective usage of assertions is not only important for the SCJP exam, but also while writing code in real life applications.<br><br> You can read more about the usage of assertions with do's and don'ts at- <br><a href="http://java.sun.com/j2se/1.4/docs/guide/lang/assert.html">http://java.sun.com/j2se/1.4/docs/guide/lang/assert.html</a><br> Also, this article at Java World discusses usage of assertions in details, though it presents a different point of view: <a href="http://www.javaworld.com/javaworld/jw-12-2001/jw-1214-assert.html">http://www.javaworld.com/javaworld/jw-12-2001/jw-1214-assert.html</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2048%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10628" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                48      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following statements about the following code is true? <br><br>1. class Test <br>2. { <br>3. public static void main(String [] args) <br>4. { <br>5. aMethod(); <br>6. } <br>7.<br> 8. static void aMethod() <br>9. { <br>10. try <br>11. { <br>12. System.out.println("abcd"); <br>13. return; <br>14. } <br>15. finally <br>16. { <br>17. System.out.println("1234"); <br>18. } <br>19. } <br>20. }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10628_50311" name="resp10628_" type="radio" value="50311">        </td>
        <td class="c1 text ">
          <label for="resp10628_50311">
            <span class="anun">a<span class="anumsep">.</span></span> An exception is thrown at line 13.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10628_50312" name="resp10628_" type="radio" value="50312">        </td>
        <td class="c1 text ">
          <label for="resp10628_50312">
            <span class="anun">b<span class="anumsep">.</span></span> The code fails to compile. The compiler complains about the return statement at line 9.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10628_50313" name="resp10628_" checked="checked" type="radio" value="50313">        </td>
        <td class="c1 text correct">
          <label for="resp10628_50313">
            <span class="anun">c<span class="anumsep">.</span></span> Prints "abcd <br> &nbsp;&nbsp;&nbsp;&nbsp;1234"            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10628_50314" name="resp10628_" type="radio" value="50314">        </td>
        <td class="c1 text ">
          <label for="resp10628_50314">
            <span class="anun">d<span class="anumsep">.</span></span> Prints "abcd "            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10628_50315" name="resp10628_" type="radio" value="50315">        </td>
        <td class="c1 text ">
          <label for="resp10628_50315">
            <span class="anun">e<span class="anumsep">.</span></span> The code fails to compile, complaining that a 'catch' clause is missing from line 15.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice C is the correct answer.<br><br> Choices A and B are incorrect since it is legal to issue a return statement inside a try block. <br><br>Choice D is incorrect because the finally block is ALWAYS executed, regardless of the presence of the return statement at line 13. <br><br>Note that the only time the finally block is not executed is when the program terminates. For example, calling the System.exit(0) method at line 13 will mean that the finally block is not executed. <br><br>Choice E is incorrect because a 'try' clause needs either a 'catch' or a 'finally', at least one of them. <br><br>Check out <a href="http://java.sun.com/docs/books/jls/third_edition/html/exceptions.html">http://java.sun.com/docs/books/jls/third_edition/html/exceptions.html</a> <br> <a href="http://java.sun.com/docs/books/tutorial/essential/exceptions/handling.html">http://java.sun.com/docs/books/tutorial/essential/exceptions/handling.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2049%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10629" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                49      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will be printed if you attempt to compile and run the following code. (Assuming the code to be in main method.) <br><br>int i = 1; <br>switch (i) <br>{ <br>
<div style="margin-left: 40px;">case 0: <br></div>
<div style="margin-left: 80px;">System.out.println("zero"); <br>break; <br></div>
<div style="margin-left: 40px;">case 1: <br>
  <div style="margin-left: 40px;">System.out.println("one");<br></div> case 2: <br>
  <div style="margin-left: 40px;">System.out.println("two");<br></div> default: <br>
  <div style="margin-left: 40px;">System.out.println("default"); break;<br></div> case 3: <br>
  <div style="margin-left: 40px;">System.out.println("three");<br></div></div> }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10629_50316" name="resp10629_" type="radio" value="50316">        </td>
        <td class="c1 text ">
          <label for="resp10629_50316">
            <span class="anun">a<span class="anumsep">.</span></span> one            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10629_50317" name="resp10629_" type="radio" value="50317">        </td>
        <td class="c1 text ">
          <label for="resp10629_50317">
            <span class="anun">b<span class="anumsep">.</span></span> one, default            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10629_50318" name="resp10629_" checked="checked" type="radio" value="50318">        </td>
        <td class="c1 text correct">
          <label for="resp10629_50318">
            <span class="anun">c<span class="anumsep">.</span></span> one, two, default            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10629_50319" name="resp10629_" type="radio" value="50319">        </td>
        <td class="c1 text ">
          <label for="resp10629_50319">
            <span class="anun">d<span class="anumsep">.</span></span> one, two, default, three            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice C is the correct answer.<br><br> The given code will continue to fall through the case statements until it encounters a break statement. Thus "one", "two", and "default" will be printed. <br><br>You can read more about the switch statement at <a href="http://java.sun.com/docs/books/jls/third_edition/html/statements.html#14.11">http://java.sun.com/docs/books/jls/third_edition/html/statements.html#14.11</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2050%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10630" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                50      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following letters are written to the standard output with the following code? <br><br>1. class Unchecked <br>2. { <br>3. public static void main(String[] args) <br>4. {<br> 5. try <br>6. { <br>7. method(); <br>8. } <br>9. catch(Exception e) { } <br>10. } <br>11. static void method() <br>12. { <br>13. try <br>14. { <br>15. wrench(); <br>16. System.out.println("a"); <br>17. } <br>18. catch(ArithmeticException e) <br>19. { <br>20. System.out.println("b"); <br>21. } <br>22. finally <br>23. { <br>24. System.out.println("c"); <br>25. } <br>26. System.out.println("d"); <br>27. } <br>28. <br>30. static void wrench() <br>31. {<br> 32. throw new NullPointerException(); <br>33. } <br>34. }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10630_50320" name="resp10630_" type="radio" value="50320">        </td>
        <td class="c1 text ">
          <label for="resp10630_50320">
            <span class="anun">a<span class="anumsep">.</span></span> "a"            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10630_50321" name="resp10630_" type="radio" value="50321">        </td>
        <td class="c1 text ">
          <label for="resp10630_50321">
            <span class="anun">b<span class="anumsep">.</span></span> "b"            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10630_50322" name="resp10630_" checked="checked" type="radio" value="50322">        </td>
        <td class="c1 text correct">
          <label for="resp10630_50322">
            <span class="anun">c<span class="anumsep">.</span></span> "c"            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10630_50323" name="resp10630_" type="radio" value="50323">        </td>
        <td class="c1 text ">
          <label for="resp10630_50323">
            <span class="anun">d<span class="anumsep">.</span></span> "d"            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice C is the correct answer.<br><br> Only the letter "c" is printed out here. The exception thrown here is NullPointerException, while the catch clause is for ArithmeticException. <br><br>So when the exception occurs, the control moves to the finally block and not to the catch block. Hence, the letters "a" and "b" are not printed, while "c" is printed. <br><br>From the finally block, the control moves to the main method, since the unhandled exception is thrown up the call stack. So "d" is not printed out either. <br><br>Read more about exception handling at <a href="http://java.sun.com/docs/books/tutorial/essential/exceptions/handling.html">http://java.sun.com/docs/books/tutorial/essential/exceptions/handling.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2051%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10621" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                51      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will happen on compiling and executing the following code fragment? <br><br>Boolean[] b1 = new Boolean[10]; <br>boolean[] b2 = new boolean[10]; <br>System.out.println("The value of b1[1] = " + b1[1]);<br> System.out.println("The value of b2[1] = " + b2[1]);</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10621_50279" name="resp10621_" type="radio" value="50279">        </td>
        <td class="c1 text ">
          <label for="resp10621_50279">
            <span class="anun">a<span class="anumsep">.</span></span> Prints "The value of b1[1] = false"<br> &nbsp;&nbsp;&nbsp;&nbsp; "The value of b2[1] = false".            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10621_50280" name="resp10621_" checked="checked" type="radio" value="50280">        </td>
        <td class="c1 text ">
          <label for="resp10621_50280">
            <span class="anun">b<span class="anumsep">.</span></span> Prints "The value of b1[1] = null" <br>&nbsp;&nbsp;&nbsp;&nbsp;"The value of b2[1] = null".            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10621_50281" name="resp10621_" type="radio" value="50281">        </td>
        <td class="c1 text correct">
          <label for="resp10621_50281">
            <span class="anun">c<span class="anumsep">.</span></span> Prints "The value of b1[1] = null" <br>&nbsp;&nbsp;&nbsp;&nbsp; "The value of b2[1] = false".            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10621_50282" name="resp10621_" type="radio" value="50282">        </td>
        <td class="c1 text ">
          <label for="resp10621_50282">
            <span class="anun">d<span class="anumsep">.</span></span> Prints "The value of b1[1] = false"   <br>&nbsp;&nbsp;&nbsp;&nbsp; "The value of b2[1] = null".            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice C is the correct answer.<br><br> When an array is constructed using the new operator, all the array elements are initialized to the default values for their data types. <br><br>By default, the default value for objects is null and for boolean primitives is false. So all the elements of the Boolean array would reference null values (i.e., they do not reference any Boolean objects) and the elements of the boolean array would be boolean primitives with false values.      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2052%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10634" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                52      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the following program with the command java Test 0 1 2? <br><br>class Test<br>{ <br>
<div style="margin-left: 40px;">public static void main(String... args)<br>{ <br>
  <div style="margin-left: 40px;">for(Object o:args) <br>
    <div style="margin-left: 40px;">System.out.print(o);<br></div> String[] s=new String[2]; <br>s=args; <br>for(int i=0;i&lt;3;i++)<br>
    <div style="margin-left: 40px;"> System.out.print(s[i]);<br></div></div> }<br></div> }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10634_50336" name="resp10634_" type="radio" value="50336">        </td>
        <td class="c1 text correct">
          <label for="resp10634_50336">
            <span class="anun">a<span class="anumsep">.</span></span> Prints 012012            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10634_50337" name="resp10634_" type="radio" value="50337">        </td>
        <td class="c1 text ">
          <label for="resp10634_50337">
            <span class="anun">b<span class="anumsep">.</span></span> Prints 01201            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10634_50338" name="resp10634_" checked="checked" type="radio" value="50338">        </td>
        <td class="c1 text ">
          <label for="resp10634_50338">
            <span class="anun">c<span class="anumsep">.</span></span> ArrayIndexOutOfBoundsException is thrown at runtime.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10634_50339" name="resp10634_" type="radio" value="50339">        </td>
        <td class="c1 text ">
          <label for="resp10634_50339">
            <span class="anun">d<span class="anumsep">.</span></span> Compiler Error            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10634_50340" name="resp10634_" type="radio" value="50340">        </td>
        <td class="c1 text ">
          <label for="resp10634_50340">
            <span class="anun">e<span class="anumsep">.</span></span> None of these            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice A is the correct answer.<br><br> This program compiles and runs without errors, printing 012012. Here, the main method uses the variable arguments (varargs) syntax to accept the command line arguments. <br><br>Varargs can be used to accept arrays. We iterate over the args array using the enhanced for loop, printing the values that are 0, 1, and 2. <br><br>We assign the args array to the reference variable s, then iterate from the array index 0 to 2, which again causes 0, 1, and 2 to be printed. Since the array index is not exceeded, no exception results here. So choice C is incorrect. <br><br>Choice D is incorrect because the code compiles fine. <br><br>Choice B is incorrect because though s was initially referring to an array of size 2, when we assign args to s, it refers to the array of size 3.<br><br> Refer <a href="http://java.sun.com/j2se/1.5.0/docs/guide/language/varargs.html">http://java.sun.com/j2se/1.5.0/docs/guide/language/varargs.html</a> for more on how to use varargs.      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2053%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10636" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                53      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Given the following code, what will be the output? <br><br>class Value <br>{ <br>
<div style="margin-left: 40px;">public int i = 15;<br></div> }<br> <br>public class Test <br>{ <br>
<div style="margin-left: 40px;">public static void main(String[] argv) <br>{<br>
  <div style="margin-left: 40px;"> Test t = new Test();<br> t.first();<br></div> }<br> public void first() <br>{<br>
  <div style="margin-left: 40px;"> int i = 5;<br> Value v = new Value();<br> v.i = 25; <br>second(v, i); <br>System.out.println(v.i);<br></div> }<br> public void second(Value v, int i) <br>{ <br>
  <div style="margin-left: 40px;">i = 0; <br>v.i = 20;<br> Value val = new Value();<br> v = val; <br>System.out.println(v.i + " " + i);<br></div> }<br></div> }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10636_50346" name="resp10636_" type="radio" value="50346">        </td>
        <td class="c1 text correct">
          <label for="resp10636_50346">
            <span class="anun">a<span class="anumsep">.</span></span> 15 0 <br>20            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10636_50347" name="resp10636_" checked="checked" type="radio" value="50347">        </td>
        <td class="c1 text ">
          <label for="resp10636_50347">
            <span class="anun">b<span class="anumsep">.</span></span> 15 0 <br>15            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10636_50348" name="resp10636_" type="radio" value="50348">        </td>
        <td class="c1 text ">
          <label for="resp10636_50348">
            <span class="anun">c<span class="anumsep">.</span></span> 20 0 <br>20            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10636_50349" name="resp10636_" type="radio" value="50349">        </td>
        <td class="c1 text ">
          <label for="resp10636_50349">
            <span class="anun">d<span class="anumsep">.</span></span> 0 15<br>20            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice A is the correct answer.<br><br> When we pass references in Java, what actually gets passed is the value of that reference (i.e., memory address of the object being referenced, and not the actual object referenced by that reference) and it gets passed as value (i.e., a copy of the reference is made). <br><br>Now when we make changes to the object referenced by that reference, the change is reflected on that object even outside of the method being called, but any changes made to the reference itself are not reflected on that reference outside of the method that is called. <br><br>In the code above, when the reference v is passed from the first() method to the second() method, the value of v is passed. When we assign the value val to v, it is valid only inside the second() method. <br><br>Thus, inside the second() method, what gets printed is 15 (initial value of i in the object referenced by val), then a blank space, and then 0 (value of the local variable i). After this, when we return to the first() method, v actually refers to the same object to which it was referring before the second() method was called. <br><br>It is worth noting that the value of i in that object (referred to by v inside the first() method) was changed to 20 in the second() method and this change does reflect even outside the second() method, hence 20 gets printed in the first() method. <br><br>Thus, the overall output of the code under consideration is <br>15 0 <br>20.<br><br> Read about how parameters are passed in Java at <a href="http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.4.1">http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.4.1</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2054%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10637" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                54      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following expressions are legal? Select three choices.<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10637_50350" name="resp10637_50350" checked="checked" type="checkbox" value="50350">        </td>
        <td class="c1 text correct">
          <label for="resp10637_50350">
            <span class="anun">a<span class="anumsep">.</span></span> String a = "Well done!!"; int b = 5; a += b;            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10637_50351" name="resp10637_50351" type="checkbox" value="50351">        </td>
        <td class="c1 text ">
          <label for="resp10637_50351">
            <span class="anun">b<span class="anumsep">.</span></span> String a = "Well done!!"; int b = 5; if (a == b) {}            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10637_50352" name="resp10637_50352" checked="checked" type="checkbox" value="50352">        </td>
        <td class="c1 text correct">
          <label for="resp10637_50352">
            <span class="anun">c<span class="anumsep">.</span></span> String a = "Well done!!"; int b = 5; a = a + b;            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10637_50353" name="resp10637_50353" type="checkbox" value="50353">        </td>
        <td class="c1 text ">
          <label for="resp10637_50353">
            <span class="anun">d<span class="anumsep">.</span></span> String a = "Well done!!"; int b = 5; b = b + a;            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10637_50354" name="resp10637_50354" checked="checked" type="checkbox" value="50354">        </td>
        <td class="c1 text correct">
          <label for="resp10637_50354">
            <span class="anun">e<span class="anumsep">.</span></span> String a = null; int b = (a != null) &amp;&amp; (a.length() &gt; 0) ? a.length() : 0;            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices A, C, and E are the correct answers.<br><br> In choice A, the use of += is treated as a shorthand for the expression in C. This attempts to "add" an int to a String, which results in conversion of the int to a String "5" in this case, and the concatenation of the two String objects. So, the value of "a" after the code is executed is "Well done!!5". <br><br>In choice B, the comparison (a == b) is not legal, since only the '+' operator performs implicit conversion to a String object. The variable b is of type int and cannot be compared with a reference value. Please note that comparison using "==" tests the values and that for objects, "value" is the reference value, and not the contents. <br><br>Choice C is identical to choice A, except the use of shorthand assignment operator. <br><br>Choice D calculates b + a, which is fine and the result is the String "5Well done". But then, it tries to assign this result to the int variable b, which is illegal. <br><br>Choice E is legal as String a is defined to be null, then compared with null, and based on this comparison, b is assigned the value a.length() or 0, both of which can be assigned to b, as b is of type int. <br><br>Please note one interesting thing here. Since a is null, calculating a.length() should raise a NullPointerException at runtime, but that won't happen here because of the use of short-circuit operator "&amp;&amp;". <br><br>What actually happens is that the first left-hand part of the expression is evaluated, i.e. a is compared to null and since this comparison results in false, the right hand part of the expression is not evaluated at all. Hence, no exception occurs at runtime and b gets the value 0.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2055%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10638" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                55      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following code fragments will compile? Select three choices.<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10638_50355" name="resp10638_50355" checked="checked" type="checkbox" value="50355">        </td>
        <td class="c1 text ">
          <label for="resp10638_50355">
            <span class="anun">a<span class="anumsep">.</span></span> int[]a=new int[10]; <br> &nbsp;&nbsp;&nbsp;&nbsp;float[] b=new float[10];<br>  &nbsp;&nbsp;&nbsp;&nbsp;b=(float[])a;            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10638_50356" name="resp10638_50356" checked="checked" type="checkbox" value="50356">        </td>
        <td class="c1 text correct">
          <label for="resp10638_50356">
            <span class="anun">b<span class="anumsep">.</span></span> Object[] obj=new Object[10]; <br> &nbsp;&nbsp;&nbsp;&nbsp;Integer[] integers=new Integer[10]; <br> &nbsp;&nbsp;&nbsp;&nbsp;obj=integers;            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10638_50357" name="resp10638_50357" type="checkbox" value="50357">        </td>
        <td class="c1 text correct">
          <label for="resp10638_50357">
            <span class="anun">c<span class="anumsep">.</span></span> Object obj=new Object(); <br> &nbsp;&nbsp;&nbsp;&nbsp;Byte[] b=new Byte[10];<br>  &nbsp;&nbsp;&nbsp;&nbsp;obj=b;            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10638_50358" name="resp10638_50358" type="checkbox" value="50358">        </td>
        <td class="c1 text ">
          <label for="resp10638_50358">
            <span class="anun">d<span class="anumsep">.</span></span> Float[] floats=new Float[10]; <br> &nbsp;&nbsp;&nbsp;&nbsp;Double[] doubles=new Double[10];<br>  &nbsp;&nbsp;&nbsp;&nbsp;doubles=floats;            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10638_50359" name="resp10638_50359" checked="checked" type="checkbox" value="50359">        </td>
        <td class="c1 text correct">
          <label for="resp10638_50359">
            <span class="anun">e<span class="anumsep">.</span></span> int i[]=new int[10];<br>  &nbsp;&nbsp;&nbsp;&nbsp;int j[]=new int[5];<br>  &nbsp;&nbsp;&nbsp;&nbsp;i=j;            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices B, C, and E are the correct answers.<br><br> Choice A will not compile because arrays of 2 different primitive types cannot be assigned to each other. <br><br>Choice B will compile because array of any Object type can be assigned to an Object array. <br><br>Choice C will compile because arrays are objects in Java, so any array object can be assigned to an Object type variable. <br><br>Choice D will not compile since the two arrays are incompatible. <br><br>Choice E will compile because an int array can be assigned to another int array.      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2056%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q16312" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                56      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which is the correct design observation ?<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16312_62027" name="resp16312_" type="radio" value="62027">        </td>
        <td class="c1 text ">
          <label for="resp16312_62027">
            <span class="anun">a<span class="anumsep">.</span></span> Low Cohesion<br> class Truck <br> { <br> String modelName;  <br> String[] engineDetails;<br> }             <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16312_62028" name="resp16312_" type="radio" value="62028">        </td>
        <td class="c1 text ">
          <label for="resp16312_62028">
            <span class="anun">b<span class="anumsep">.</span></span> High Cohesion<br> class Truck <br> { <br> String modelName; <br> String[] passengerList;  <br> String[] cargoList; <br> }            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16312_62029" name="resp16312_" checked="checked" type="radio" value="62029">        </td>
        <td class="c1 text correct">
          <label for="resp16312_62029">
            <span class="anun">c<span class="anumsep">.</span></span> Tight coupling <br> class Truck <br> { <br> Driver driver; <br> Price price; <br> void printDriverDetails(){}  <br> void printPrice(){} <br> }             <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16312_62030" name="resp16312_" type="radio" value="62030">        </td>
        <td class="c1 text ">
          <label for="resp16312_62030">
            <span class="anun">d<span class="anumsep">.</span></span> None of the above.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        ANSWER : C<br><br>The public interface of a class is cohesive if all of its features are related to the concept that the class represents. Here, the Truck class contains model name and engine details only, in the code fragment A, which are clearly its features. <br><br>In code fragment B, the list of passengers and cargo has been added as its features, which indicates low cohesion because these actually are not the parts of a truck. <br><br>Choice C indicates tight coupling because the Truck class has been made to depend upon the Driver and Price classes, which is totally unnecessary here. <br><br>More about coupling, cohesion and other related concepts is available at<br><a href="http://satc.gsfc.nasa.gov/support/STC_APR98/apply_oo/apply_oo.html" target="_blank">http://satc.gsfc.nasa.gov/support/STC_APR98/apply_oo/apply_oo.html </a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2057%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q16313" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                57      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the output when the following code is run.<br><br>abstract class Parent <br>{ <br>static void f() <br>{ <br>System.out.println("Parent"); <br>} <br>protected Parent(int i){} <br>} <br>class Child extends Parent <br>{ <br>static void f() <br>{ <br>System.out.println("Child"); <br>} <br>Child()<br>{ <br> <br>} <br>public static void main(String[] args) <br>{ <br>Parent p=new Parent(); <br>p.f(); <br>} <br>} <br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16313_62031" name="resp16313_" type="radio" value="62031">        </td>
        <td class="c1 text ">
          <label for="resp16313_62031">
            <span class="anun">a<span class="anumsep">.</span></span> Parent.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16313_62032" name="resp16313_" checked="checked" type="radio" value="62032">        </td>
        <td class="c1 text correct">
          <label for="resp16313_62032">
            <span class="anun">b<span class="anumsep">.</span></span> Compilation error.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16313_62033" name="resp16313_" type="radio" value="62033">        </td>
        <td class="c1 text ">
          <label for="resp16313_62033">
            <span class="anun">c<span class="anumsep">.</span></span> Child.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16313_62034" name="resp16313_" type="radio" value="62034">        </td>
        <td class="c1 text ">
          <label for="resp16313_62034">
            <span class="anun">d<span class="anumsep">.</span></span> Exception at runtime.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        ANSWER : B<br><br>Explanation:<br>Here, the Parent class is abstract, so it cannot be instantiated. So, <br><br>Parent p=new Parent(); <br><br>would not be allowed.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2058%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10635" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                58      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Suppose class Jasmine extends class Flower. Which of the following choices will compile correctly, given the following code? Select three choices.<br><br>Jasmine j=new Jasmine(); <br>Flower f=new Flower();</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10635_50341" name="resp10635_50341" checked="checked" type="checkbox" value="50341">        </td>
        <td class="c1 text correct">
          <label for="resp10635_50341">
            <span class="anun">a<span class="anumsep">.</span></span> f=j;            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10635_50342" name="resp10635_50342" checked="checked" type="checkbox" value="50342">        </td>
        <td class="c1 text correct">
          <label for="resp10635_50342">
            <span class="anun">b<span class="anumsep">.</span></span> f=(Flower)j;            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10635_50343" name="resp10635_50343" checked="checked" type="checkbox" value="50343">        </td>
        <td class="c1 text correct">
          <label for="resp10635_50343">
            <span class="anun">c<span class="anumsep">.</span></span> j=(Jasmine)f;            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10635_50344" name="resp10635_50344" type="checkbox" value="50344">        </td>
        <td class="c1 text ">
          <label for="resp10635_50344">
            <span class="anun">d<span class="anumsep">.</span></span> j=f;            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10635_50345" name="resp10635_50345" type="checkbox" value="50345">        </td>
        <td class="c1 text ">
          <label for="resp10635_50345">
            <span class="anun">e<span class="anumsep">.</span></span> j=(Flower)f;            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices A, B and C are the correct answers.<br><br> Choice A is correct because a subclass object can be assigned to a superclass type variable without a cast. <br><br>Choice B is also correct, though the cast is unnecessary here. <br><br>Choice C is correct and choice D is incorrect because the cast is necessary when assigning from the superclass to the subclass. <br><br>Choice E is incorrect because f has to be cast to Jasmine, and not to Flower (f is already of type Flower).      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2059%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10642" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                59      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will be printed when you execute the following code? <br><br>class X <br> { <br>
<div style="margin-left: 40px;">Y b = new Y();<br> X() <br>{ <br>
  <div style="margin-left: 40px;">System.out.print("X"); <br></div>}<br></div> }<br> class Y <br>{ <br>
<div style="margin-left: 40px;">Y() <br>{ <br>
  <div style="margin-left: 40px;">System.out.print("Y"); <br></div>} <br></div>}<br> public class Z extends X <br>{ <br>
<div style="margin-left: 40px;">Y y = new Y(); <br>Z() <br>{ <br>
  <div style="margin-left: 40px;">System.out.print("Z"); <br></div>}<br> public static void main(String[] args) <br>{ <br>
  <div style="margin-left: 40px;">new Z(); <br></div>} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10642_50373" name="resp10642_" type="radio" value="50373">        </td>
        <td class="c1 text ">
          <label for="resp10642_50373">
            <span class="anun">a<span class="anumsep">.</span></span> Z            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10642_50374" name="resp10642_" type="radio" value="50374">        </td>
        <td class="c1 text ">
          <label for="resp10642_50374">
            <span class="anun">b<span class="anumsep">.</span></span> YZ            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10642_50375" name="resp10642_" type="radio" value="50375">        </td>
        <td class="c1 text ">
          <label for="resp10642_50375">
            <span class="anun">c<span class="anumsep">.</span></span> XYZ            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10642_50376" name="resp10642_" checked="checked" type="radio" value="50376">        </td>
        <td class="c1 text correct">
          <label for="resp10642_50376">
            <span class="anun">d<span class="anumsep">.</span></span> YXYZ            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice D is the correct answer.<br><br> Before any object is constructed, the object of the parent class is constructed (as there is a default call to the parent's constructor from the constructor of the child class via the super() statement.) <br><br>Also note that when an object is constructed, the variables are initialized first and then the constructor is executed. So, when new Z() is executed, the object of class X will be constructed, which means Y b = new Y() will be executed and "Y" will be printed, as a result. <br><br>After that, the constructor of X will be called which implies "X" will be printed. Now the object of Z will be constructed and thus Y y = new Y() will be executed, and "Y" will be printed. <br><br>Finally, the constructor Z() will be called and thus "Z" will be printed. Thus, YXYZ will be printed.<br><br> Read more about invoking superclass constructors at <a href="http://www.javaworld.com/jw-10-2000/jw-1013-constructors.html">http://www.javaworld.com/jw-10-2000/jw-1013-constructors.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2060%20of%20Quiz%20Final%20Test%20(ID:%201778),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q10643" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                60      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Consider the class hierarchy described below: <br><br>interface DrivingUtilities{} <br>class FourWheeler implements DrivingUtilities{} <br>class Car extends FourWheeler{} <br>class Truck extends FourWheeler{} <br>class Bus extends FourWheeler{} <br>class Crane extends FourWheeler{} <br><br>Consider the following code excerpts below:<br><br> 1. DrivingUtilities du=null;<br> 2. FourWheeler fw=null;<br> 3. Truck myTruck = new Truck();<br> 4. du = (DrivingUtilities)myTruck;<br> 5. fw = new Crane();<br> 6. fw = du; <br>Which of the following statements are true? Select two choices.<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10643_50377" name="resp10643_50377" type="checkbox" value="50377">        </td>
        <td class="c1 text ">
          <label for="resp10643_50377">
            <span class="anun">a<span class="anumsep">.</span></span> The code will compile if we put an explicit cast at line 6 but will throw an exception            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10643_50378" name="resp10643_50378" checked="checked" type="checkbox" value="50378">        </td>
        <td class="c1 text ">
          <label for="resp10643_50378">
            <span class="anun">b<span class="anumsep">.</span></span> The code will compile and run without errors.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp10643_50379" name="resp10643_50379" type="checkbox" value="50379">        </td>
        <td class="c1 text correct">
          <label for="resp10643_50379">
            <span class="anun">c<span class="anumsep">.</span></span> The code will not compile without an explicit cast at line 6            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp10643_50380" name="resp10643_50380" type="checkbox" value="50380">        </td>
        <td class="c1 text correct">
          <label for="resp10643_50380">
            <span class="anun">d<span class="anumsep">.</span></span> The code at line 4 will compile even without the explicit cast.            <img src="./OCPJP 6 - Exam Simulator  Final Test_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices C and D are the correct answers.<br><br> Choice C is correct because a supertype cannot be assigned to a subtype variable without casting. Here we are trying to assign du, which is of type DrivingUtilities to fw which is of type FourWheeler. This is allowed only with the following cast. <br><br>fw = (FourWheeler)du; <br><br>Choice D is correct because no explicit cast is needed at line 4, because we are a subtype to a supertype variable (this is always allowed even without a cast). <br><br>Choice A is incorrect because if we put an explicit cast at line 6, the code will compile and run perfectly fine, no exception will be thrown because the runtime class of du (that is Truck) can be converted to type FourWheeler without any problem. <br><br>This is possible since Truck is a subtype of FourWheeler. Since line 6 will not compile, choice B is also incorrect.<br><br> More information is available at <a href="http://java.sun.com/docs/books/jls/third_edition/html/conversions.html#5.5">http://java.sun.com/docs/books/jls/third_edition/html/conversions.html#5.5</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>

<div class="controls">
<div class="singlebutton"><form action="http://www.whizlabs.com/examprep/mod/quiz/view.php" method="get"><div><input type="hidden" name="id" value="2206"><input type="submit" value="Finish review"></div></form></div></div>
<!--Start - Display Buttons with their course prices in each moodle pages: Devesh M-->
				
		<!--Start - Display Buy Mock Exam Full Version button with price at trial course page only: Devesh M-->
				<!--End - Display Buy Mock Exam Full Version button with price at trial course page only: Devesh M-->
  <div id="leftfooter" style="display: none; "></div><div id="rightfooter" style="display: none; "><p class="footertopma">Thanks Whizlabs for such an excellent product. It really helped me a lot for my achivement. -Nazmul<span class="more"><a href="http://www.whizlabs.com/examprep/mod/quiz/review.php?attempt=170846&showall=true#" class="amore"> more</a></span></p>

  </div>

  <div id="rightfooter2" style="display: none; "><p class="copyright">Whizlabs Copyright (C) 2011. All Rights Reserved.</p></div>
<script language="javascript">
	if(document.getElementById("left-column")) {
	
	}
	else {
		document.getElementById('leftfooter').style.display='none';
		document.getElementById('rightfooter').style.display='none';
		document.getElementById('rightfooter2').style.display='none';
	}
</script>
  <div id="footerbottom">
    
 <center>
	<div style="border:0px solid #FFFFFF; font-size:11px; font-family:Arial, Helvetica, sans-serif; font-weight:bold; color:#000;">
		<br>
		<span><a href="http://www.whizlabs.com/scja/scja.html" title="SCJA Certification" style="text-decoration:none; color:#000;">SCJA Certification</a></span> |
		<span><a href="http://www.whizlabs.com/scjp/scjp.html" title="SCJP Certification" style="text-decoration:none; color:#000;">SCJP Certification</a></span> |
		<span><a href="http://www.whizlabs.com/scwcd/scwcd.html" title="SCWCD Certification" style="text-decoration:none; color:#000;">SCWCD Certification</a></span> |
		<span><a href="http://www.whizlabs.com/scbcd/scbcd.html" title="SCBCD Certification" style="text-decoration:none; color:#000;">SCBCD Certification</a></span> |
		<span><a href="http://www.whizlabs.com/scdjws/scdjws.html" title="SCDJWS Certification" style="text-decoration:none; color:#000;">SCDJWS Certification</a></span> |
		<span><a href="http://www.whizlabs.com/scmad/scmad.html" title="SCMAD Certification" style="text-decoration:none; color:#000;">SCMAD Certification</a></span> |
		<span><a href="http://www.whizlabs.com/scea/scea.html" title="SCEA Certification" style="text-decoration:none; color:#000;">SCEA Certification</a></span>

		<br><br>
		<span><a href="http://www.whizlabs.com/otherpages/legal.html" alt="coming soon" style="text-decoration:none; color:#000;">Legal</a></span> |
		<span><a href="http://www.whizlabs.com/otherpages/policies.html" alt="coming soon" style="text-decoration:none; color:#000;">Policies</a></span> |
		<span><a href="http://www.whizlabs.com/otherpages/copyrights-and-trademarks.html" alt="coming soon" style="text-decoration:none; color:#000;"> Copyrights and Trademarks</a></span>
	</div>
	<br>
</center>
</div>
 </div>

<!--End - Display Buttons with their course prices in each moodle pages: Devesh M-->
<!--Footer links for each moodle pages-->


<!--Google Adwords Code Start: Devesh M-->
	<!--quiz/review.php--> 
	<!-- Google Code for Trial Test Reviewed Conversion Page --> 
	<script type="text/javascript">
	<!--
	var google_conversion_id = 1071861065;
	var google_conversion_language = "en";
	var google_conversion_format = "2";
	var google_conversion_color = "ffffff";
	var google_conversion_label = "YhFjCNjMogEQyZqN_wM"; var google_conversion_value = 0; //--> </script> <script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Final Test_files/conversion.js">
	</script><iframe name="google_conversion_frame" width="200" height="26" src="./OCPJP 6 - Exam Simulator  Final Test_files/saved_resource.htm" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no">&lt;img height="1" width="1" border="0" src="http://www.googleadservices.com/pagead/conversion/1071861065/?frame=0&amp;random=1324343305435&amp;cv=7&amp;fst=1324343305435&amp;num=1&amp;fmt=2&amp;value=0&amp;label=YhFjCNjMogEQyZqN_wM&amp;bg=ffffff&amp;hl=en&amp;guid=ON&amp;u_h=1080&amp;u_w=1920&amp;u_ah=1080&amp;u_aw=1920&amp;u_cd=32&amp;u_his=25&amp;u_tz=-120&amp;u_java=true&amp;u_nplug=27&amp;u_nmime=117&amp;ref=http%3A//www.whizlabs.com/examprep/mod/quiz/review.php%3Fattempt%3D170846&amp;url=http%3A//www.whizlabs.com/examprep/mod/quiz/review.php%3Fattempt%3D170846%26showall%3Dtrue" /&gt;</iframe>
	<noscript>
	&lt;div style="display:inline;"&gt;
	&lt;img height="1" width="1" style="border-style:none;" alt=""
	src="http://www.googleadservices.com/pagead/conversion/1071861065/?label=YhF
	jCNjMogEQyZqN_wM&amp;amp;guid=ON&amp;amp;script=0"/&gt;
	&lt;/div&gt;
	</noscript>
<!--Google Adwords Code End : Devesh M-->

<!--OnTarget Code Start: Devesh M-->
<script language="JavaScript">
	var s_PageName = "OCPJP 6 - Exam Simulator: Final Test";

			</script>

<!--End of OnTarget Code: Devesh M-->

<!-- Start of Google Analytics Code: Devesh M-->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script><script src="./OCPJP 6 - Exam Simulator  Final Test_files/ga.js" type="text/javascript"></script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-320509-1");
pageTracker._trackPageview();
} catch(err) {}</script>
<!--End of Google Analytics Code: Devesh M-->



</body><span id="skype_highlighting_settings" display="none" autoextractnumbers="1"></span><object id="skype_plugin_object" location.href="http://www.whizlabs.com/examprep/mod/quiz/review.php?attempt=170846&amp;showall=true" location.hostname="www.whizlabs.com" style="position: absolute; visibility: hidden; left: -100px; top: -100px; " width="0" height="0" type="application/x-vnd.skype.click2call.chrome.5.6.0"></object></html>